diff options
Diffstat (limited to 'source4/torture')
156 files changed, 8881 insertions, 7412 deletions
diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c index e97338d3a6..23269a0160 100644 --- a/source4/torture/auth/ntlmssp.c +++ b/source4/torture/auth/ntlmssp.c @@ -44,7 +44,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) gensec_start_mech_by_oid(gensec_security, GENSEC_OID_NTLMSSP), "Failed to start GENSEC for NTLMSSP"); - gensec_ntlmssp_state = gensec_security->private_data; + gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data; gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405060708090a0b0c0d0e0f00"); dump_data_pw("NTLMSSP session key: \n", @@ -98,7 +98,7 @@ static bool torture_ntlmssp_self_check(struct torture_context *tctx) gensec_start_mech_by_oid(gensec_security, GENSEC_OID_NTLMSSP), "GENSEC start mech by oid"); - gensec_ntlmssp_state = gensec_security->private_data; + gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data; gensec_ntlmssp_state->session_key = strhex_to_data_blob("0102030405e538b0"); dump_data_pw("NTLMSSP session key: \n", diff --git a/source4/torture/basic/aliases.c b/source4/torture/basic/aliases.c index 0b5f1fb88a..660009704b 100644 --- a/source4/torture/basic/aliases.c +++ b/source4/torture/basic/aliases.c @@ -381,9 +381,9 @@ static bool setpathinfo_aliases(struct torture_context *tctx, /* look for aliased info levels in trans2 calls */ -struct torture_suite *torture_trans2_aliases(void) +struct torture_suite *torture_trans2_aliases(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "ALIASES"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "ALIASES"); torture_suite_add_1smb_test(suite, "QFILEINFO aliases", qfsinfo_aliases); torture_suite_add_1smb_test(suite, "QFSINFO aliases", qfileinfo_aliases); diff --git a/source4/torture/basic/attr.c b/source4/torture/basic/attr.c index 4c6a7a3ab6..07071bb68a 100644 --- a/source4/torture/basic/attr.c +++ b/source4/torture/basic/attr.c @@ -86,8 +86,8 @@ static const struct trunc_open_results attr_results[] = { }; -BOOL torture_openattrtest(struct torture_context *tctx, - struct smbcli_state *cli1) +bool torture_openattrtest(struct torture_context *tctx, + struct smbcli_state *cli1) { const char *fname = "\\openattr.file"; int fnum1; diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c index bfe1e082f1..1415b4195f 100644 --- a/source4/torture/basic/base.c +++ b/source4/torture/basic/base.c @@ -29,6 +29,7 @@ #include "librpc/gen_ndr/ndr_nbt.h" #include "lib/events/events.h" #include "lib/cmdline/popt_common.h" +#include "param/param.h" #define CHECK_MAX_FAILURES(label) do { if (++failures >= torture_failures) goto label; } while (0) @@ -40,7 +41,7 @@ static struct smbcli_state *open_nbt_connection(struct torture_context *tctx) struct smbcli_state *cli; const char *host = torture_setting_string(tctx, "host", NULL); - make_nbt_name_client(&calling, lp_netbios_name()); + make_nbt_name_client(&calling, lp_netbios_name(global_loadparm)); nbt_choose_called_name(NULL, &called, host, NBT_NAME_SERVER); @@ -67,12 +68,12 @@ failed: return NULL; } -static BOOL tcon_devtest(struct torture_context *tctx, +static bool tcon_devtest(struct torture_context *tctx, struct smbcli_state *cli, const char *myshare, const char *devtype, NTSTATUS expected_error) { - BOOL status; + bool status; const char *password = torture_setting_string(tctx, "password", NULL); status = NT_STATUS_IS_OK(smbcli_tconX(cli, myshare, devtype, @@ -157,13 +158,13 @@ static bool run_fdpasstest(struct torture_context *tctx, /** This checks how the getatr calls works */ -static BOOL run_attrtest(struct torture_context *tctx, +static bool run_attrtest(struct torture_context *tctx, struct smbcli_state *cli) { int fnum; time_t t, t2; const char *fname = "\\attrib123456789.tst"; - BOOL correct = True; + bool correct = true; smbcli_unlink(cli->tree, fname); fnum = smbcli_open(cli->tree, fname, @@ -172,7 +173,7 @@ static BOOL run_attrtest(struct torture_context *tctx, if (NT_STATUS_IS_ERR(smbcli_getatr(cli->tree, fname, NULL, NULL, &t))) { torture_comment(tctx, "getatr failed (%s)\n", smbcli_errstr(cli->tree)); - correct = False; + correct = false; } torture_comment(tctx, "New file time is %s", ctime(&t)); @@ -181,7 +182,7 @@ static BOOL run_attrtest(struct torture_context *tctx, torture_comment(tctx, "ERROR: SMBgetatr bug. time is %s", ctime(&t)); t = time(NULL); - correct = False; + correct = false; } t2 = t-60*60*24; /* 1 day ago */ @@ -190,12 +191,12 @@ static BOOL run_attrtest(struct torture_context *tctx, if (NT_STATUS_IS_ERR(smbcli_setatr(cli->tree, fname, 0, t2))) { torture_comment(tctx, "setatr failed (%s)\n", smbcli_errstr(cli->tree)); - correct = True; + correct = true; } if (NT_STATUS_IS_ERR(smbcli_getatr(cli->tree, fname, NULL, NULL, &t))) { torture_comment(tctx, "getatr failed (%s)\n", smbcli_errstr(cli->tree)); - correct = True; + correct = true; } torture_comment(tctx, "Retrieved file time as %s", ctime(&t)); @@ -204,7 +205,7 @@ static BOOL run_attrtest(struct torture_context *tctx, torture_comment(tctx, "ERROR: getatr/setatr bug. times are\n%s", ctime(&t)); torture_comment(tctx, "%s", ctime(&t2)); - correct = True; + correct = true; } smbcli_unlink(cli->tree, fname); @@ -215,7 +216,7 @@ static BOOL run_attrtest(struct torture_context *tctx, /** This checks a couple of trans2 calls */ -static BOOL run_trans2test(struct torture_context *tctx, +static bool run_trans2test(struct torture_context *tctx, struct smbcli_state *cli) { int fnum; @@ -225,7 +226,7 @@ static BOOL run_trans2test(struct torture_context *tctx, const char *dname = "\\trans2"; const char *fname2 = "\\trans2\\trans2.tst"; const char *pname; - BOOL correct = True; + bool correct = true; smbcli_unlink(cli->tree, fname); @@ -236,20 +237,20 @@ static BOOL run_trans2test(struct torture_context *tctx, if (NT_STATUS_IS_ERR(smbcli_qfileinfo(cli->tree, fnum, NULL, &size, &c_time, &a_time, &m_time, NULL, NULL))) { torture_comment(tctx, "ERROR: qfileinfo failed (%s)\n", smbcli_errstr(cli->tree)); - correct = False; + correct = false; } torture_comment(tctx, "Testing NAME_INFO\n"); if (NT_STATUS_IS_ERR(smbcli_qfilename(cli->tree, fnum, &pname))) { torture_comment(tctx, "ERROR: qfilename failed (%s)\n", smbcli_errstr(cli->tree)); - correct = False; + correct = false; } if (!pname || strcmp(pname, fname)) { torture_comment(tctx, "qfilename gave different name? [%s] [%s]\n", fname, pname); - correct = False; + correct = false; } smbcli_close(cli->tree, fnum); @@ -259,7 +260,7 @@ static BOOL run_trans2test(struct torture_context *tctx, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); if (fnum == -1) { torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } smbcli_close(cli->tree, fnum); @@ -267,7 +268,7 @@ static BOOL run_trans2test(struct torture_context *tctx, if (NT_STATUS_IS_ERR(smbcli_qpathinfo(cli->tree, fname, &c_time, &a_time, &m_time, &size, NULL))) { torture_comment(tctx, "ERROR: qpathinfo failed (%s)\n", smbcli_errstr(cli->tree)); - correct = False; + correct = false; } else { if (c_time != m_time) { torture_comment(tctx, "create time=%s", ctime(&c_time)); @@ -277,12 +278,12 @@ static BOOL run_trans2test(struct torture_context *tctx, if (a_time % (60*60) == 0) { torture_comment(tctx, "access time=%s", ctime(&a_time)); torture_comment(tctx, "This system appears to set a midnight access time\n"); - correct = False; + correct = false; } if (abs(m_time - time(NULL)) > 60*60*24*7) { torture_comment(tctx, "ERROR: totally incorrect times - maybe word reversed? mtime=%s", ctime(&m_time)); - correct = False; + correct = false; } } @@ -293,12 +294,12 @@ static BOOL run_trans2test(struct torture_context *tctx, smbcli_close(cli->tree, fnum); if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, fname, &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) { torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree)); - correct = False; + correct = false; } else { if (w_time < 60*60*24*2) { torture_comment(tctx, "write time=%s", ctime(&w_time)); torture_comment(tctx, "This system appears to set a initial 0 write time\n"); - correct = False; + correct = false; } } @@ -309,12 +310,12 @@ static BOOL run_trans2test(struct torture_context *tctx, when creating a new file */ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, dname))) { torture_comment(tctx, "ERROR: mkdir failed (%s)\n", smbcli_errstr(cli->tree)); - correct = False; + correct = false; } sleep(3); if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) { torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree)); - correct = False; + correct = false; } fnum = smbcli_open(cli->tree, fname2, @@ -323,11 +324,11 @@ static BOOL run_trans2test(struct torture_context *tctx, smbcli_close(cli->tree, fnum); if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time2, &w_time, &size, NULL, NULL))) { torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree)); - correct = False; + correct = false; } else { if (m_time2 == m_time) { torture_comment(tctx, "This system does not update directory modification times\n"); - correct = False; + correct = false; } } smbcli_unlink(cli->tree, fname2); @@ -337,17 +338,17 @@ static BOOL run_trans2test(struct torture_context *tctx, } /* send smb negprot commands, not reading the response */ -static BOOL run_negprot_nowait(struct torture_context *tctx) +static bool run_negprot_nowait(struct torture_context *tctx) { int i; struct smbcli_state *cli, *cli2; - BOOL correct = True; + bool correct = true; torture_comment(tctx, "starting negprot nowait test\n"); cli = open_nbt_connection(tctx); if (!cli) { - return False; + return false; } torture_comment(tctx, "Filling send buffer\n"); @@ -363,7 +364,7 @@ static BOOL run_negprot_nowait(struct torture_context *tctx) } else { torture_comment(tctx, "Failed to fill pipe - %s \n", nt_errstr(req->status)); torture_close_connection(cli); - return False; + return false; } } } @@ -371,12 +372,12 @@ static BOOL run_negprot_nowait(struct torture_context *tctx) torture_comment(tctx, "Opening secondary connection\n"); if (!torture_open_connection(&cli2, 1)) { torture_comment(tctx, "Failed to open secondary connection\n"); - correct = False; + correct = false; } if (!torture_close_connection(cli2)) { torture_comment(tctx, "Failed to close secondary connection\n"); - correct = False; + correct = false; } torture_close_connection(cli); @@ -388,14 +389,14 @@ static BOOL run_negprot_nowait(struct torture_context *tctx) this checks to see if a secondary tconx can use open files from an earlier tconx */ -static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli) +static bool run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli) { const char *fname = "\\tcontest.tmp"; int fnum1; uint16_t cnum1, cnum2, cnum3; uint16_t vuid1, vuid2; uint8_t buf[4]; - BOOL ret = True; + bool ret = true; struct smbcli_tree *tree1; const char *host = torture_setting_string(tctx, "host", NULL); const char *share = torture_setting_string(tctx, "share", NULL); @@ -408,16 +409,16 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } cnum1 = cli->tree->tid; vuid1 = cli->session->vuid; - memset(&buf, 0, 4); /* init buf so valgrind won't complain */ + memset(buf, 0, 4); /* init buf so valgrind won't complain */ if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) != 4) { torture_comment(tctx, "initial write failed (%s)\n", smbcli_errstr(cli->tree)); - return False; + return false; } tree1 = cli->tree; /* save old tree connection */ @@ -425,7 +426,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli torture_comment(tctx, "%s refused 2nd tree connect (%s)\n", host, smbcli_errstr(cli->tree)); talloc_free(cli); - return False; + return false; } cnum2 = cli->tree->tid; @@ -437,7 +438,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) { torture_comment(tctx, "* server allows write with wrong TID\n"); - ret = False; + ret = false; } else { torture_comment(tctx, "server fails write with wrong TID : %s\n", smbcli_errstr(cli->tree)); } @@ -448,7 +449,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) { torture_comment(tctx, "* server allows write with invalid TID\n"); - ret = False; + ret = false; } else { torture_comment(tctx, "server fails write with invalid TID : %s\n", smbcli_errstr(cli->tree)); } @@ -459,7 +460,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) { torture_comment(tctx, "* server allows write with invalid VUID\n"); - ret = False; + ret = false; } else { torture_comment(tctx, "server fails write with invalid VUID : %s\n", smbcli_errstr(cli->tree)); } @@ -469,14 +470,14 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum1))) { torture_comment(tctx, "close failed (%s)\n", smbcli_errstr(cli->tree)); - return False; + return false; } cli->tree->tid = cnum2; if (NT_STATUS_IS_ERR(smbcli_tdis(cli))) { torture_comment(tctx, "secondary tdis failed (%s)\n", smbcli_errstr(cli->tree)); - return False; + return false; } cli->tree = tree1; /* restore initial tree */ @@ -490,7 +491,7 @@ static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli /** checks for correct tconX support */ -static BOOL run_tcon_devtype_test(struct torture_context *tctx, +static bool run_tcon_devtype_test(struct torture_context *tctx, struct smbcli_state *cli1) { const char *share = torture_setting_string(tctx, "share", NULL); @@ -528,7 +529,7 @@ static BOOL run_tcon_devtype_test(struct torture_context *tctx, return true; } -static BOOL rw_torture2(struct torture_context *tctx, +static bool rw_torture2(struct torture_context *tctx, struct smbcli_state *c1, struct smbcli_state *c2) { const char *lockfname = "\\torture2.lck"; @@ -537,7 +538,7 @@ static BOOL rw_torture2(struct torture_context *tctx, int i; uint8_t buf[131072]; uint8_t buf_rd[131072]; - BOOL correct = True; + bool correct = true; ssize_t bytes_read, bytes_written; torture_assert(tctx, smbcli_deltree(c1->tree, lockfname) != -1, @@ -574,14 +575,14 @@ static BOOL rw_torture2(struct torture_context *tctx, if ((bytes_written = smbcli_write(c1->tree, fnum1, 0, buf, 0, buf_size)) != buf_size) { torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c1->tree)); torture_comment(tctx, "wrote %d, expected %d\n", (int)bytes_written, (int)buf_size); - correct = False; + correct = false; break; } if ((bytes_read = smbcli_read(c2->tree, fnum2, buf_rd, 0, buf_size)) != buf_size) { torture_comment(tctx, "read failed (%s)\n", smbcli_errstr(c2->tree)); torture_comment(tctx, "read %d, expected %d\n", (int)bytes_read, (int)buf_size); - correct = False; + correct = false; break; } @@ -623,16 +624,16 @@ static bool run_readwritetest(struct torture_context *tctx, /* test the timing of deferred open requests */ -static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli, int dummy) +static bool run_deferopen(struct torture_context *tctx, struct smbcli_state *cli, int dummy) { const char *fname = "\\defer_open_test.dat"; int retries=4; int i = 0; - BOOL correct = True; + bool correct = true; if (retries <= 0) { torture_comment(tctx, "failed to connect\n"); - return False; + return false; } torture_comment(tctx, "Testing deferred open requests.\n"); @@ -662,7 +663,7 @@ static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli if (fnum == -1) { torture_comment(tctx,"Failed to open %s, error=%s\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } torture_comment(tctx, "pid %u open %d\n", (unsigned)getpid(), i); @@ -671,7 +672,7 @@ static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli i++; if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { torture_comment(tctx,"Failed to close %s, error=%s\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } sleep(2); } @@ -680,7 +681,7 @@ static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli /* All until the last unlink will fail with sharing violation. */ if (!NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) { torture_comment(tctx, "unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - correct = False; + correct = false; } } @@ -692,7 +693,7 @@ static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli Try with a wrong vuid and check error message. */ -static BOOL run_vuidtest(struct torture_context *tctx, +static bool run_vuidtest(struct torture_context *tctx, struct smbcli_state *cli) { const char *fname = "\\vuid.tst"; @@ -743,7 +744,7 @@ static BOOL run_vuidtest(struct torture_context *tctx, /* Test open mode returns on read-only files. */ - static BOOL run_opentest(struct torture_context *tctx, struct smbcli_state *cli1, + static bool run_opentest(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { const char *fname = "\\readonly.file"; @@ -751,7 +752,7 @@ static BOOL run_vuidtest(struct torture_context *tctx, int fnum1, fnum2; uint8_t buf[20]; size_t fsize; - BOOL correct = True; + bool correct = true; char *tmp_path; int failures = 0; int i; @@ -786,25 +787,25 @@ static BOOL run_vuidtest(struct torture_context *tctx, fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "close2 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_setatr(cli1->tree, fname, FILE_ATTRIBUTE_READONLY, 0))) { torture_comment(tctx, "smbcli_setatr failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test1); - return False; + return false; } fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE); if (fnum1 == -1) { torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test1); - return False; + return false; } /* This will fail - but the error should be ERRnoaccess, not ERRbadshare. */ @@ -826,7 +827,7 @@ error_test1: fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE); if (fnum1 == -1) { torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } /* This will fail - but the error should be ERRshare. */ @@ -839,7 +840,7 @@ error_test1: if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "close2 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; + return false; } smbcli_unlink(cli1->tree, fname); @@ -851,7 +852,7 @@ error_test1: fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { torture_comment(tctx, "(3) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } /* write 20 bytes. */ @@ -860,25 +861,25 @@ error_test1: if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) { torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(cli1->tree)); - correct = False; + correct = false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "(3) close1 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; + return false; } /* Ensure size == 20. */ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) { torture_comment(tctx, "(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test3); - return False; + return false; } if (fsize != 20) { torture_comment(tctx, "(3) file size != 20\n"); CHECK_MAX_FAILURES(error_test3); - return False; + return false; } /* Now test if we can truncate a file opened for readonly. */ @@ -887,25 +888,25 @@ error_test1: if (fnum1 == -1) { torture_comment(tctx, "(3) open (2) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test3); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "close2 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; + return false; } /* Ensure size == 0. */ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) { torture_comment(tctx, "(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test3); - return False; + return false; } if (fsize != 0) { torture_comment(tctx, "(3) file size != 0\n"); CHECK_MAX_FAILURES(error_test3); - return False; + return false; } torture_comment(tctx, "finished open test 3\n"); error_test3: @@ -917,7 +918,7 @@ error_test3: if (fnum1 == -1) { torture_comment(tctx, "ctemp failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test4); - return False; + return false; } torture_comment(tctx, "ctemp gave path %s\n", tmp_path); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { @@ -940,7 +941,7 @@ error_test4: if (fnum1 == -1) { torture_comment(tctx, "test 1 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test10); - return False; + return false; } fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, @@ -948,16 +949,16 @@ error_test4: if (fnum2 == -1) { torture_comment(tctx, "test 1 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test10); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { torture_comment(tctx, "test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); - return False; + return false; } torture_comment(tctx, "non-io open test #1 passed.\n"); @@ -972,7 +973,7 @@ error_test10: if (fnum1 == -1) { torture_comment(tctx, "test 2 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test20); - return False; + return false; } fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, @@ -981,16 +982,16 @@ error_test10: if (fnum2 == -1) { torture_comment(tctx, "test 2 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test20); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { torture_comment(tctx, "test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } torture_comment(tctx, "non-io open test #2 passed.\n"); @@ -1005,7 +1006,7 @@ error_test20: if (fnum1 == -1) { torture_comment(tctx, "test 3 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test30); - return False; + return false; } fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, @@ -1014,16 +1015,16 @@ error_test20: if (fnum2 == -1) { torture_comment(tctx, "test 3 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test30); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "test 3 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { torture_comment(tctx, "test 3 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); - return False; + return false; } torture_comment(tctx, "non-io open test #3 passed.\n"); @@ -1038,7 +1039,7 @@ error_test30: if (fnum1 == -1) { torture_comment(tctx, "test 4 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test40); - return False; + return false; } fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, @@ -1047,14 +1048,14 @@ error_test30: if (fnum2 != -1) { torture_comment(tctx, "test 4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test40); - return False; + return false; } torture_comment(tctx, "test 4 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation"); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "test 4 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } torture_comment(tctx, "non-io open test #4 passed.\n"); @@ -1069,7 +1070,7 @@ error_test40: if (fnum1 == -1) { torture_comment(tctx, "test 5 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test50); - return False; + return false; } fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, @@ -1078,17 +1079,17 @@ error_test40: if (fnum2 == -1) { torture_comment(tctx, "test 5 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test50); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "test 5 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { torture_comment(tctx, "test 5 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); - return False; + return false; } torture_comment(tctx, "non-io open test #5 passed.\n"); @@ -1103,7 +1104,7 @@ error_test50: if (fnum1 == -1) { torture_comment(tctx, "test 6 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test60); - return False; + return false; } fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, @@ -1112,17 +1113,17 @@ error_test50: if (fnum2 == -1) { torture_comment(tctx, "test 6 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test60); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "test 6 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { torture_comment(tctx, "test 6 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); - return False; + return false; } torture_comment(tctx, "non-io open test #6 passed.\n"); @@ -1137,7 +1138,7 @@ error_test60: if (fnum1 == -1) { torture_comment(tctx, "test 7 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test70); - return False; + return false; } fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, @@ -1146,14 +1147,14 @@ error_test60: if (fnum2 != -1) { torture_comment(tctx, "test 7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test70); - return False; + return false; } torture_comment(tctx, "test 7 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation"); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "test 7 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } torture_comment(tctx, "non-io open test #7 passed.\n"); @@ -1167,7 +1168,7 @@ error_test70: fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { torture_comment(tctx, "(8) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } /* write 20 bytes. */ @@ -1176,56 +1177,56 @@ error_test70: if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) { torture_comment(tctx, "(8) write failed (%s)\n", smbcli_errstr(cli1->tree)); - correct = False; + correct = false; } /* Ensure size == 20. */ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) { torture_comment(tctx, "(8) getatr (1) failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test80); - return False; + return false; } if (fsize != 20) { torture_comment(tctx, "(8) file size != 20\n"); CHECK_MAX_FAILURES(error_test80); - return False; + return false; } /* Get an exclusive lock on the open file. */ if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK))) { torture_comment(tctx, "(8) lock1 failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test80); - return False; + return false; } fnum2 = smbcli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE); if (fnum1 == -1) { torture_comment(tctx, "(8) open (2) of %s with truncate failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; + return false; } /* Ensure size == 0. */ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) { torture_comment(tctx, "(8) getatr (2) failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test80); - return False; + return false; } if (fsize != 0) { torture_comment(tctx, "(8) file size != 0\n"); CHECK_MAX_FAILURES(error_test80); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { torture_comment(tctx, "(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { torture_comment(tctx, "(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; + return false; } error_test80: @@ -1314,7 +1315,7 @@ static bool run_iometer(struct torture_context *tctx, ops = 0; - while (True) { + while (true) { int i, num_reads, num_writes; num_reads = random() % 10; @@ -1350,11 +1351,11 @@ static bool run_iometer(struct torture_context *tctx, /** tries variants of chkpath */ -static BOOL torture_chkpath_test(struct torture_context *tctx, +static bool torture_chkpath_test(struct torture_context *tctx, struct smbcli_state *cli) { int fnum; - BOOL ret; + bool ret; torture_comment(tctx, "Testing valid and invalid paths\n"); @@ -1365,29 +1366,29 @@ static BOOL torture_chkpath_test(struct torture_context *tctx, if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\chkpath.dir"))) { torture_comment(tctx, "mkdir1 failed : %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\chkpath.dir\\dir2"))) { torture_comment(tctx, "mkdir2 failed : %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } fnum = smbcli_open(cli->tree, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { torture_comment(tctx, "open1 failed (%s)\n", smbcli_errstr(cli->tree)); - return False; + return false; } smbcli_close(cli->tree, fnum); if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir"))) { torture_comment(tctx, "chkpath1 failed: %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; } if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\dir2"))) { torture_comment(tctx, "chkpath2 failed: %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; } if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\foo.txt"))) { @@ -1395,7 +1396,7 @@ static BOOL torture_chkpath_test(struct torture_context *tctx, NT_STATUS_NOT_A_DIRECTORY); } else { torture_comment(tctx, "* chkpath on a file should fail\n"); - ret = False; + ret = false; } if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\bar.txt"))) { @@ -1403,7 +1404,7 @@ static BOOL torture_chkpath_test(struct torture_context *tctx, NT_STATUS_OBJECT_NAME_NOT_FOUND); } else { torture_comment(tctx, "* chkpath on a non existent file should fail\n"); - ret = False; + ret = false; } if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\dirxx\\bar.txt"))) { @@ -1411,7 +1412,7 @@ static BOOL torture_chkpath_test(struct torture_context *tctx, NT_STATUS_OBJECT_PATH_NOT_FOUND); } else { torture_comment(tctx, "* chkpath on a non existent component should fail\n"); - ret = False; + ret = false; } smbcli_rmdir(cli->tree, "\\chkpath.dir\\dir2"); @@ -1425,11 +1426,11 @@ static BOOL torture_chkpath_test(struct torture_context *tctx, * This is a test to excercise some weird Samba3 error paths. */ -static BOOL torture_samba3_errorpaths(struct torture_context *tctx) +static bool torture_samba3_errorpaths(struct torture_context *tctx) { - BOOL nt_status_support; + bool nt_status_support; struct smbcli_state *cli_nt = NULL, *cli_dos = NULL; - BOOL result = False; + bool result = false; int fnum; const char *os2_fname = ".+,;=[]."; const char *dname = "samba3_errordir"; @@ -1439,12 +1440,12 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx) if (mem_ctx == NULL) { torture_comment(tctx, "talloc_init failed\n"); - return False; + return false; } - nt_status_support = lp_nt_status_support(); + nt_status_support = lp_nt_status_support(global_loadparm); - if (!lp_set_cmdline("nt status support", "yes")) { + if (!lp_set_cmdline(global_loadparm, "nt status support", "yes")) { torture_comment(tctx, "Could not set 'nt status support = yes'\n"); goto fail; } @@ -1453,7 +1454,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx) goto fail; } - if (!lp_set_cmdline("nt status support", "no")) { + if (!lp_set_cmdline(global_loadparm, "nt status support", "no")) { torture_comment(tctx, "Could not set 'nt status support = yes'\n"); goto fail; } @@ -1462,7 +1463,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx) goto fail; } - if (!lp_set_cmdline("nt status support", + if (!lp_set_cmdline(global_loadparm, "nt status support", nt_status_support ? "yes":"no")) { torture_comment(tctx, "Could not reset 'nt status support = yes'"); goto fail; @@ -1633,7 +1634,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx) torture_comment(tctx, "ntcreate as dir gave %s, " "expected NT_STATUS_NOT_A_DIRECTORY\n", nt_errstr(status)); - result = False; + result = false; } if (NT_STATUS_IS_OK(status)) { @@ -1646,7 +1647,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx) torture_comment(tctx, "ntcreate as dir gave %s, " "expected NT_STATUS_NOT_A_DIRECTORY\n", nt_errstr(status)); - result = False; + result = false; } if (NT_STATUS_IS_OK(status)) { @@ -1657,7 +1658,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx) smbcli_unlink(cli_nt->tree, fname); } - if (!torture_setting_bool(tctx, "samba3", False)) { + if (!torture_setting_bool(tctx, "samba3", false)) { goto done; } @@ -1696,7 +1697,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx) } done: - result = True; + result = true; fail: if (cli_dos != NULL) { @@ -1712,11 +1713,10 @@ static BOOL torture_samba3_errorpaths(struct torture_context *tctx) NTSTATUS torture_base_init(void) { - struct torture_suite *suite = torture_suite_create( - talloc_autofree_context(), "BASE"); + struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "BASE"); torture_suite_add_2smb_test(suite, "FDPASS", run_fdpasstest); - torture_suite_add_suite(suite, torture_base_locktest()); + torture_suite_add_suite(suite, torture_base_locktest(suite)); torture_suite_add_1smb_test(suite, "UNLINK", torture_unlinktest); torture_suite_add_1smb_test(suite, "ATTR", run_attrtest); torture_suite_add_1smb_test(suite, "TRANS2", run_trans2test); @@ -1742,17 +1742,16 @@ NTSTATUS torture_base_init(void) torture_suite_add_1smb_test(suite, "PROPERTIES", torture_test_properties); torture_suite_add_1smb_test(suite, "MANGLE", torture_mangle); torture_suite_add_1smb_test(suite, "OPENATTR", torture_openattrtest); - torture_suite_add_1smb_test(suite, "CHARSET", torture_charset); + torture_suite_add_suite(suite, torture_charset(suite)); torture_suite_add_1smb_test(suite, "CHKPATH", torture_chkpath_test); torture_suite_add_1smb_test(suite, "SECLEAK", torture_sec_leak); torture_suite_add_simple_test(suite, "DISCONNECT", torture_disconnect); torture_suite_add_suite(suite, torture_delay_write()); - torture_suite_add_simple_test(suite, "SAMBA3ERROR", - torture_samba3_errorpaths); + torture_suite_add_simple_test(suite, "SAMBA3ERROR", torture_samba3_errorpaths); torture_suite_add_1smb_test(suite, "CASETABLE", torture_casetable); torture_suite_add_1smb_test(suite, "UTABLE", torture_utable); torture_suite_add_simple_test(suite, "SMB", torture_smb_scan); - torture_suite_add_suite(suite, torture_trans2_aliases()); + torture_suite_add_suite(suite, torture_trans2_aliases(suite)); torture_suite_add_1smb_test(suite, "TRANS2-SCAN", torture_trans2_scan); torture_suite_add_1smb_test(suite, "NTTRANS", torture_nttrans_scan); diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c index 3fa094e05c..b1e3b96c2b 100644 --- a/source4/torture/basic/charset.c +++ b/source4/torture/basic/charset.c @@ -33,7 +33,7 @@ the prefix BASEDIR is added before the name */ static NTSTATUS unicode_open(struct torture_context *tctx, - struct smbcli_tree *tree, + struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, uint32_t open_disposition, const uint32_t *u_name, @@ -82,7 +82,7 @@ static NTSTATUS unicode_open(struct torture_context *tctx, io.ntcreatex.in.fname = fname2; io.ntcreatex.in.open_disposition = open_disposition; - status = smb_raw_open(tree, mem_ctx, &io); + status = smb_raw_open(tree, tctx, &io); talloc_free(ucs_name); @@ -93,172 +93,118 @@ static NTSTATUS unicode_open(struct torture_context *tctx, /* see if the server recognises composed characters */ -static BOOL test_composed(struct torture_context *tctx, - struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_composed(struct torture_context *tctx, + struct smbcli_state *cli) { const uint32_t name1[] = {0x61, 0x308}; const uint32_t name2[] = {0xe4}; NTSTATUS status1, status2; - printf("Testing composite character (a umlaut)\n"); - - status1 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 2); - if (!NT_STATUS_IS_OK(status1)) { - printf("Failed to create composed name - %s\n", - nt_errstr(status1)); - return False; - } + torture_assert(tctx, torture_setup_dir(cli, BASEDIR), + "setting up basedir"); - status2 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1); + status1 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 2); + torture_assert_ntstatus_ok(tctx, status1, "Failed to create composed name"); - if (!NT_STATUS_IS_OK(status2)) { - printf("Failed to create accented character - %s\n", - nt_errstr(status2)); - return False; - } + status2 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 1); + + torture_assert_ntstatus_ok(tctx, status2, "Failed to create accented character"); - return True; + return true; } /* see if the server recognises a naked diacritical */ -static BOOL test_diacritical(struct torture_context *tctx, - struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_diacritical(struct torture_context *tctx, + struct smbcli_state *cli) { const uint32_t name1[] = {0x308}; const uint32_t name2[] = {0x308, 0x308}; NTSTATUS status1, status2; - printf("Testing naked diacritical (umlaut)\n"); - - status1 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1); + torture_assert(tctx, torture_setup_dir(cli, BASEDIR), + "setting up basedir"); - if (!NT_STATUS_IS_OK(status1)) { - printf("Failed to create naked diacritical - %s\n", - nt_errstr(status1)); - return False; - } + status1 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 1); + + torture_assert_ntstatus_ok(tctx, status1, "Failed to create naked diacritical"); /* try a double diacritical */ - status2 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 2); + status2 = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 2); - if (!NT_STATUS_IS_OK(status2)) { - printf("Failed to create double naked diacritical - %s\n", - nt_errstr(status2)); - return False; - } + torture_assert_ntstatus_ok(tctx, status2, "Failed to create double naked diacritical"); - return True; + return true; } /* see if the server recognises a partial surrogate pair */ -static BOOL test_surrogate(struct torture_context *tctx, - struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_surrogate(struct torture_context *tctx, + struct smbcli_state *cli) { const uint32_t name1[] = {0xd800}; const uint32_t name2[] = {0xdc00}; const uint32_t name3[] = {0xd800, 0xdc00}; NTSTATUS status; - printf("Testing partial surrogate\n"); + torture_assert(tctx, torture_setup_dir(cli, BASEDIR), + "setting up basedir"); - status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1); + status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 1); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to create partial surrogate 1 - %s\n", - nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "Failed to create partial surrogate 1"); - status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1); + status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 1); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to create partial surrogate 2 - %s\n", - nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "Failed to create partial surrogate 2"); - status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 2); + status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name3, 2); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to create full surrogate - %s\n", - nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "Failed to create full surrogate"); - return True; + return true; } /* see if the server recognises wide-a characters */ -static BOOL test_widea(struct torture_context *tctx, - struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_widea(struct torture_context *tctx, + struct smbcli_state *cli) { const uint32_t name1[] = {'a'}; const uint32_t name2[] = {0xff41}; const uint32_t name3[] = {0xff21}; NTSTATUS status; - printf("Testing wide-a\n"); - - status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1); + torture_assert(tctx, torture_setup_dir(cli, BASEDIR), + "setting up basedir"); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to create 'a' - %s\n", - nt_errstr(status)); - return False; - } + status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name1, 1); - status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1); + torture_assert_ntstatus_ok(tctx, status, "Failed to create 'a'"); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to create wide-a - %s\n", - nt_errstr(status)); - return False; - } + status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name2, 1); - status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 1); + torture_assert_ntstatus_ok(tctx, status, "Failed to create wide-a"); - if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { - printf("Expected %s creating wide-A - %s\n", - nt_errstr(NT_STATUS_OBJECT_NAME_COLLISION), - nt_errstr(status)); - return False; - } + status = unicode_open(tctx, cli->tree, tctx, NTCREATEX_DISP_CREATE, name3, 1); - return True; + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OBJECT_NAME_COLLISION, + "Failed to create wide-A"); + + return true; } -BOOL torture_charset(struct torture_context *tctx, struct smbcli_state *cli) +struct torture_suite *torture_charset(TALLOC_CTX *mem_ctx) { - BOOL ret = True; - TALLOC_CTX *mem_ctx; - - mem_ctx = talloc_init("torture_charset"); - - if (!torture_setup_dir(cli, BASEDIR)) { - return False; - } - - if (!test_composed(tctx, cli, mem_ctx)) { - ret = False; - } + struct torture_suite *suite = torture_suite_create(mem_ctx, "CHARSET"); - if (!test_diacritical(tctx, cli, mem_ctx)) { - ret = False; - } - - if (!test_surrogate(tctx, cli, mem_ctx)) { - ret = False; - } - - if (!test_widea(tctx, cli, mem_ctx)) { - ret = False; - } + torture_suite_add_1smb_test(suite, "Testing composite character (a umlaut)", test_composed); + torture_suite_add_1smb_test(suite, "Testing naked diacritical (umlaut)", test_diacritical); + torture_suite_add_1smb_test(suite, "Testing partial surrogate", test_surrogate); + torture_suite_add_1smb_test(suite, "Testing wide-a", test_widea); - return ret; + return suite; } diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c index 289e08ae59..8928754e1a 100644 --- a/source4/torture/basic/delaywrite.c +++ b/source4/torture/basic/delaywrite.c @@ -31,24 +31,24 @@ #define BASEDIR "\\delaywrite" -static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcli_state *cli) +static bool test_delayed_write_update(struct torture_context *tctx, struct smbcli_state *cli) { union smb_fileinfo finfo1, finfo2; const char *fname = BASEDIR "\\torture_file.txt"; NTSTATUS status; int fnum1 = -1; - BOOL ret = True; + bool ret = true; ssize_t written; time_t t; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { torture_comment(tctx, "Failed to open %s\n", fname); - return False; + return false; } finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO; @@ -59,7 +59,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return False; + return false; } torture_comment(tctx, "Initial write time %s\n", @@ -74,7 +74,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl if (written != 1) { torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); - return False; + return false; } t = time(NULL); @@ -84,7 +84,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - ret = False; + ret = false; break; } torture_comment(tctx, "write time %s\n", @@ -100,7 +100,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) { torture_comment(tctx, "Server did not update write time?!\n"); - ret = False; + ret = false; } @@ -116,7 +116,7 @@ static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcl * Do as above, but using 2 connections. */ -static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbcli_state *cli, +static bool test_delayed_write_update2(struct torture_context *tctx, struct smbcli_state *cli, struct smbcli_state *cli2) { union smb_fileinfo finfo1, finfo2; @@ -124,19 +124,19 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc NTSTATUS status; int fnum1 = -1; int fnum2 = -1; - BOOL ret = True; + bool ret = true; ssize_t written; time_t t; union smb_flush flsh; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { torture_comment(tctx, "Failed to open %s\n", fname); - return False; + return false; } finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO; @@ -147,7 +147,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return False; + return false; } torture_comment(tctx, "Initial write time %s\n", @@ -180,7 +180,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("sfileinfo failed: %s\n", nt_errstr(status))); - return False; + return false; } } @@ -193,7 +193,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - ret = False; + ret = false; break; } torture_comment(tctx, "write time %s\n", @@ -209,7 +209,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) { torture_comment(tctx, "Server did not update write time?!\n"); - ret = False; + ret = false; } /* Now try a write to see if the write time gets reset. */ @@ -222,7 +222,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return False; + return false; } torture_comment(tctx, "Modified write time %s\n", @@ -236,7 +236,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (written != 10) { torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); - return False; + return false; } /* Just to prove to tridge that the an smbflush has no effect on @@ -249,7 +249,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc status = smb_raw_flush(cli->tree, &flsh); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("smbflush failed: %s\n", nt_errstr(status))); - return False; + return false; } t = time(NULL); @@ -262,7 +262,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - ret = False; + ret = false; break; } torture_comment(tctx, "write time %s\n", @@ -283,7 +283,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE); if (fnum2 == -1) { torture_comment(tctx, "Failed to open %s\n", fname); - return False; + return false; } torture_comment(tctx, "Doing a 10 byte write to extend the file via second fd and see if this changes the last write time.\n"); @@ -293,14 +293,14 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (written != 10) { torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); - return False; + return false; } status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return False; + return false; } torture_comment(tctx, "write time %s\n", nt_time_string(tctx, finfo2.basic_info.out.write_time)); @@ -319,7 +319,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (written != 10) { torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); - return False; + return false; } finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO; @@ -329,7 +329,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return False; + return false; } torture_comment(tctx, "write time %s\n", nt_time_string(tctx, finfo2.basic_info.out.write_time)); @@ -347,7 +347,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - ret = False; + ret = false; break; } torture_comment(tctx, "write time %s\n", @@ -373,7 +373,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc fnum1 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE); if (fnum1 == -1) { torture_comment(tctx, "Failed to open %s\n", fname); - return False; + return false; } finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO; @@ -384,7 +384,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return False; + return false; } torture_comment(tctx, "Second open initial write time %s\n", @@ -398,7 +398,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (written != 10) { torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); - return False; + return false; } finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO; @@ -408,7 +408,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - return False; + return false; } torture_comment(tctx, "write time %s\n", nt_time_string(tctx, finfo2.basic_info.out.write_time)); @@ -426,7 +426,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); - ret = False; + ret = false; break; } torture_comment(tctx, "write time %s\n", @@ -468,7 +468,7 @@ static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbc * nasty.... */ -static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_state *cli, +static bool test_finfo_after_write(struct torture_context *tctx, struct smbcli_state *cli, struct smbcli_state *cli2) { union smb_fileinfo finfo1, finfo2; @@ -476,16 +476,16 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s NTSTATUS status; int fnum1 = -1; int fnum2; - BOOL ret = True; + bool ret = true; ssize_t written; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - ret = False; + ret = false; torture_result(tctx, TORTURE_FAIL, __location__": unable to open %s", fname); goto done; } @@ -496,7 +496,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status)); goto done; } @@ -507,7 +507,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s if (written != 1) { torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1", (int)written); - ret = False; + ret = false; goto done; } @@ -515,7 +515,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s if (fnum2 == -1) { torture_result(tctx, TORTURE_FAIL, __location__": failed to open 2nd time - %s", smbcli_errstr(cli2->tree)); - ret = False; + ret = false; goto done; } @@ -524,7 +524,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s if (written != 1) { torture_result(tctx, TORTURE_FAIL, __location__": written gave %d - should have been 1", (int)written); - ret = False; + ret = false; goto done; } @@ -536,21 +536,21 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status)); - ret = False; + ret = false; goto done; } if (finfo1.basic_info.out.create_time != finfo2.basic_info.out.create_time) { torture_result(tctx, TORTURE_FAIL, __location__": create_time changed"); - ret = False; + ret = false; goto done; } if (finfo1.basic_info.out.access_time != finfo2.basic_info.out.access_time) { torture_result(tctx, TORTURE_FAIL, __location__": access_time changed"); - ret = False; + ret = false; goto done; } @@ -560,14 +560,14 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s "write time conn 1 = %s, conn 2 = %s", nt_time_string(tctx, finfo1.basic_info.out.write_time), nt_time_string(tctx, finfo2.basic_info.out.write_time)); - ret = False; + ret = false; goto done; } if (finfo1.basic_info.out.change_time != finfo2.basic_info.out.change_time) { torture_result(tctx, TORTURE_FAIL, __location__": change_time changed"); - ret = False; + ret = false; goto done; } @@ -587,7 +587,7 @@ static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_s if (!NT_STATUS_IS_OK(status)) { torture_result(tctx, TORTURE_FAIL, __location__": fileinfo failed: %s", nt_errstr(status)); - ret = False; + ret = false; goto done; } diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 93b282272f..38528cd845 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -144,7 +144,7 @@ static bool deltest1(struct torture_context *tctx, struct smbcli_state *cli1, st torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", fname)); - return True; + return true; } /* Test 2 - this should delete the file on close. */ @@ -163,7 +163,7 @@ static bool deltest2(struct torture_context *tctx, struct smbcli_state *cli1, st talloc_asprintf(tctx, "open of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); @@ -178,7 +178,7 @@ static bool deltest2(struct torture_context *tctx, struct smbcli_state *cli1, st if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { printf("(%s) close failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - return False; + return false; } smbcli_unlink(cli1->tree, fname); } @@ -227,7 +227,7 @@ static bool deltest3(struct torture_context *tctx, struct smbcli_state *cli1, st fname, smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + smbcli_nt_delete_on_close(cli1->tree, fnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); @@ -250,9 +250,9 @@ static bool deltest3(struct torture_context *tctx, struct smbcli_state *cli1, st __location__, smbcli_errstr(cli1->tree)); } smbcli_unlink(cli1->tree, fname); - return False; + return false; } - return True; + return true; } /* Test 4 ... */ @@ -260,7 +260,7 @@ static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, st { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -292,7 +292,7 @@ static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, st smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + smbcli_nt_delete_on_close(cli1->tree, fnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); @@ -328,13 +328,13 @@ static bool deltest5(struct torture_context *tctx, struct smbcli_state *cli1, st /* This should fail - only allowed on NT opens with DELETE access. */ - torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)), + torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, true)), "setting delete_on_close on OpenX file succeeded - should fail !"); torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); - return True; + return true; } /* Test 6 ... */ @@ -358,7 +358,7 @@ static bool deltest6(struct torture_context *tctx, struct smbcli_state *cli1, st /* This should fail - only allowed on NT opens with DELETE access. */ torture_assert(tctx, - !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)), + !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, true)), "setting delete_on_close on file with no delete access succeeded - should fail !"); torture_assert_ntstatus_ok(tctx, @@ -366,14 +366,14 @@ static bool deltest6(struct torture_context *tctx, struct smbcli_state *cli1, st talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); - return True; + return true; } /* Test 7 ... */ static bool deltest7(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -387,16 +387,16 @@ static bool deltest7(struct torture_context *tctx, struct smbcli_state *cli1, st torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, true), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, False), + smbcli_nt_delete_on_close(cli1->tree, fnum1, false), "unsetting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); @@ -419,7 +419,7 @@ static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, st { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -447,18 +447,18 @@ static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, st fname, smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + smbcli_nt_delete_on_close(cli1->tree, fnum1, true), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__); torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), talloc_asprintf(tctx, "close - 1 failed (%s)", smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, -1, fname, True, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, true, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__); torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2), talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli2->tree))); @@ -490,7 +490,7 @@ static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, st talloc_asprintf(tctx, "open of %s succeeded should have failed!", fname)); - return True; + return true; } /* Test 10 ... */ @@ -544,7 +544,7 @@ static bool deltest11(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True); + status = smbcli_nt_delete_on_close(cli1->tree, fnum1, true); torture_assert_ntstatus_equal(tctx, status, NT_STATUS_CANNOT_DELETE, talloc_asprintf(tctx, "setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)", smbcli_errstr(cli1->tree))); @@ -553,7 +553,7 @@ static bool deltest11(struct torture_context *tctx, struct smbcli_state *cli1, s talloc_asprintf(tctx, "close failed (%s)", smbcli_errstr(cli1->tree))); - return True; + return true; } /* Test 12 ... */ @@ -593,7 +593,7 @@ static bool deltest13(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -631,18 +631,18 @@ static bool deltest13(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, - True), + true), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__); torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli2->tree, fnum2, - False), + false), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), talloc_asprintf(tctx, "close - 1 failed (%s)", @@ -684,10 +684,10 @@ static bool deltest14(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__); - torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, True), + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, false, __location__); + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, true), "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(tctx, cli1, dnum1, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, true, __location__); smbcli_close(cli1->tree, dnum1); /* Now it should be gone... */ @@ -751,7 +751,7 @@ static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, s talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname_new, smbcli_errstr(cli1->tree))); - status = smbcli_nt_delete_on_close(cli2->tree, fnum2, True); + status = smbcli_nt_delete_on_close(cli2->tree, fnum2, true); torture_assert_ntstatus_ok(tctx, status, "setting delete_on_close on file failed !"); @@ -761,7 +761,7 @@ static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, s /* The file should be around under the new name, there's a second * handle open */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname_new, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname_new, true, __location__); fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_GENERIC_ALL, @@ -775,7 +775,7 @@ static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); smbcli_close(cli2->tree, fnum2); smbcli_close(cli1->tree, fnum1); @@ -840,11 +840,11 @@ static bool deltest16(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert (tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, false, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, @@ -860,15 +860,15 @@ static bool deltest16(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); - correct &= check_delete_on_close(tctx, cli2, -1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, true, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, true, __location__); smbcli_close(cli2->tree, fnum2); @@ -885,7 +885,7 @@ static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -926,7 +926,7 @@ static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, s fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -944,12 +944,12 @@ static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, s fname, smbcli_errstr(cli1->tree))); /* still not reported as being set on either */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, fname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, fname, false, __location__); smbcli_close(cli1->tree, fnum2); @@ -966,7 +966,7 @@ static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -994,7 +994,7 @@ static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, s dname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, @@ -1011,12 +1011,12 @@ static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); - correct &= check_delete_on_close(tctx, cli1, fnum2, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, true, __location__); smbcli_close(cli1->tree, fnum2); @@ -1040,7 +1040,7 @@ static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -1082,7 +1082,7 @@ static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, s talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, false, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, @@ -1100,7 +1100,7 @@ static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, s smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, true, __location__); smbcli_close(cli1->tree, fnum2); @@ -1127,15 +1127,15 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s { int fnum1 = -1; int dnum1 = -1; - bool correct = True; + bool correct = true; NTSTATUS status; del_clean_area(cli1, cli2); /* Test 20 -- non-empty directory hardest to get right... */ - if (torture_setting_bool(tctx, "samba3", False)) { - return True; + if (torture_setting_bool(tctx, "samba3", false)) { + return true; } smbcli_deltree(cli1->tree, dname); @@ -1153,8 +1153,8 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__); - status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, false, __location__); + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, true); { char *fullname; @@ -1172,7 +1172,7 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s "smbcli_open failed"); } - status = smbcli_nt_delete_on_close(cli1->tree, dnum1, False); + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, false); torture_assert_ntstatus_ok(tctx, status, "setting delete_on_close on file failed !"); @@ -1187,7 +1187,7 @@ static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, s smbcli_close(cli1->tree, fnum1); } - status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); + status = smbcli_nt_delete_on_close(cli1->tree, dnum1, true); torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DIRECTORY_NOT_EMPTY, "setting delete_on_close failed"); @@ -1201,7 +1201,7 @@ static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -1239,12 +1239,12 @@ static bool deltest20a(struct torture_context *tctx, struct smbcli_state *cli1, fname, smbcli_errstr(cli2->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); smbcli_close(cli2->tree, fnum2); @@ -1267,7 +1267,7 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, { int fnum1 = -1; int fnum2 = -1; - bool correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -1322,12 +1322,12 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, fname, smbcli_errstr(cli2->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, false, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, false, __location__); /* Rename the file by handle. */ @@ -1349,7 +1349,7 @@ static bool deltest20b(struct torture_context *tctx, struct smbcli_state *cli1, fname, fname_new, smbcli_errstr(cli2->tree))); } - correct &= check_delete_on_close(tctx, cli2, fnum2, fname_new, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname_new, false, __location__); smbcli_close(cli2->tree, fnum2); @@ -1371,13 +1371,13 @@ static bool deltest21(struct torture_context *tctx) int fnum1 = -1; struct smbcli_state *cli1; struct smbcli_state *cli2; - bool correct = True; + bool correct = true; if (!torture_open_connection(&cli1, 0)) - return False; + return false; if (!torture_open_connection(&cli2, 1)) - return False; + return false; del_clean_area(cli1, cli2); @@ -1392,12 +1392,12 @@ static bool deltest21(struct torture_context *tctx) fname, smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok(tctx, - smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + smbcli_nt_delete_on_close(cli1->tree, fnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); /* Ensure delete on close is set. */ - correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, true, __location__); /* Now yank the rug from under cli1. */ smbcli_transport_dead(cli1->transport, NT_STATUS_LOCAL_DISCONNECT); @@ -1405,7 +1405,7 @@ static bool deltest21(struct torture_context *tctx) fnum1 = -1; if (!torture_open_connection(&cli1, 0)) { - return False; + return false; } /* On slow build farm machines it might happen that they are not fast @@ -1438,10 +1438,10 @@ static bool deltest22(struct torture_context *tctx) int dnum1 = -1; int dnum2 = -1; struct smbcli_state *cli1; - bool correct = True; + bool correct = true; if (!torture_open_connection(&cli1, 0)) - return False; + return false; smbcli_deltree(cli1->tree, dname); @@ -1480,7 +1480,7 @@ static bool deltest22(struct torture_context *tctx) dname, smbcli_errstr(cli1->tree))); torture_assert_ntstatus_ok( - tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, True), + tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, true), talloc_asprintf(tctx, "setting delete_on_close failed (%s)", smbcli_errstr(cli1->tree))); diff --git a/source4/torture/basic/denytest.c b/source4/torture/basic/denytest.c index 98f4323ce6..bc64d4b2ff 100644 --- a/source4/torture/basic/denytest.c +++ b/source4/torture/basic/denytest.c @@ -1410,12 +1410,12 @@ static void progress_bar(struct torture_context *tctx, uint_t i, uint_t total) /* this produces a matrix of deny mode behaviour for 1 connection */ -BOOL torture_denytest1(struct torture_context *tctx, - struct smbcli_state *cli1) +bool torture_denytest1(struct torture_context *tctx, + struct smbcli_state *cli1) { int fnum1, fnum2; int i; - BOOL correct = True; + bool correct = true; struct timeval tv, tv_start; const char *fnames[2] = {"\\denytest1.dat", "\\denytest1.exe"}; int failures=0; @@ -1461,7 +1461,7 @@ BOOL torture_denytest1(struct torture_context *tctx, } } - if (torture_setting_bool(tctx, "showall", False) || + if (torture_setting_bool(tctx, "showall", false) || res != denytable1[i].result) { int64_t tdif; GetTimeOfDay(&tv); @@ -1479,7 +1479,7 @@ BOOL torture_denytest1(struct torture_context *tctx, } if (res != denytable1[i].result) { - correct = False; + correct = false; CHECK_MAX_FAILURES(failed); } @@ -1500,13 +1500,13 @@ failed: /* this produces a matrix of deny mode behaviour with 2 connections */ -BOOL torture_denytest2(struct torture_context *tctx, - struct smbcli_state *cli1, - struct smbcli_state *cli2) +bool torture_denytest2(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { int fnum1, fnum2; int i; - BOOL correct = True; + bool correct = true; const char *fnames[2] = {"\\denytest2.dat", "\\denytest2.exe"}; struct timeval tv, tv_start; int failures=0; @@ -1548,7 +1548,7 @@ BOOL torture_denytest2(struct torture_context *tctx, } } - if (torture_setting_bool(tctx, "showall", False) || + if (torture_setting_bool(tctx, "showall", false) || res != denytable2[i].result) { int64_t tdif; GetTimeOfDay(&tv); @@ -1566,7 +1566,7 @@ BOOL torture_denytest2(struct torture_context *tctx, } if (res != denytable2[i].result) { - correct = False; + correct = false; CHECK_MAX_FAILURES(failed); } @@ -1588,9 +1588,9 @@ failed: /* simple test harness for playing with deny modes */ -BOOL torture_denytest3(struct torture_context *tctx, - struct smbcli_state *cli1, - struct smbcli_state *cli2) +bool torture_denytest3(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { int fnum1, fnum2; const char *fname; @@ -1616,7 +1616,7 @@ BOOL torture_denytest3(struct torture_context *tctx, smbcli_unlink(cli1->tree, fname); torture_comment(tctx, "fnum1=%d fnum2=%d\n", fnum1, fnum2); - return True; + return true; } struct bit_value { @@ -1645,7 +1645,7 @@ static const char *bit_string(TALLOC_CTX *mem_ctx, const struct bit_value *bv, i if (ret == NULL) { ret = talloc_asprintf(mem_ctx, "%s", bv[i].name); } else { - ret = talloc_asprintf_append(ret, " | %s", bv[i].name); + ret = talloc_asprintf_append_buffer(ret, " | %s", bv[i].name); } } } @@ -1658,7 +1658,7 @@ static const char *bit_string(TALLOC_CTX *mem_ctx, const struct bit_value *bv, i determine if two opens conflict */ static NTSTATUS predict_share_conflict(uint32_t sa1, uint32_t am1, uint32_t sa2, uint32_t am2, - BOOL read_for_execute, enum deny_result *res) + bool read_for_execute, enum deny_result *res) { #define CHECK_MASK(am, sa, right, share) do { \ if (((am) & (right)) && !((sa) & (share))) { \ @@ -1721,7 +1721,7 @@ static NTSTATUS predict_share_conflict(uint32_t sa1, uint32_t am1, uint32_t sa2, /* a denytest for ntcreatex */ -static BOOL torture_ntdenytest(struct torture_context *tctx, +static bool torture_ntdenytest(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2, int client) { const struct bit_value share_access_bits[] = { @@ -1741,7 +1741,7 @@ static BOOL torture_ntdenytest(struct torture_context *tctx, }; int fnum1; int i; - BOOL correct = True; + bool correct = true; struct timeval tv, tv_start; const char *fname; int nbits1 = ARRAY_SIZE(share_access_bits); @@ -1787,7 +1787,7 @@ static BOOL torture_ntdenytest(struct torture_context *tctx, int b_am1 = random() & ((1<<nbits2)-1); int b_sa2 = random() & ((1<<nbits1)-1); int b_am2 = random() & ((1<<nbits2)-1); - BOOL read_for_execute; + bool read_for_execute; progress_bar(tctx, i, torture_numops); @@ -1801,9 +1801,9 @@ static BOOL torture_ntdenytest(struct torture_context *tctx, status2 = smb_raw_open(cli2->tree, mem_ctx, &io2); if (random() % 2 == 0) { - read_for_execute = True; + read_for_execute = true; } else { - read_for_execute = False; + read_for_execute = false; } if (!NT_STATUS_IS_OK(status1)) { @@ -1853,7 +1853,7 @@ static BOOL torture_ntdenytest(struct torture_context *tctx, GetTimeOfDay(&tv); tdif = usec_time_diff(&tv, &tv_start); tdif /= 1000; - if (torture_setting_bool(tctx, "showall", False) || + if (torture_setting_bool(tctx, "showall", false) || !NT_STATUS_EQUAL(status2, status2_p) || res != res2) { torture_comment(tctx, "\n%-20s %-70s\n%-20s %-70s %4s %4s %s/%s\n", @@ -1871,7 +1871,7 @@ static BOOL torture_ntdenytest(struct torture_context *tctx, if (res != res2 || !NT_STATUS_EQUAL(status2, status2_p)) { CHECK_MAX_FAILURES(failed); - correct = False; + correct = false; } talloc_free(mem_ctx); @@ -1889,7 +1889,8 @@ failed: /* a denytest for ntcreatex */ -BOOL torture_ntdenytest1(struct torture_context *tctx, struct smbcli_state *cli, int client) +bool torture_ntdenytest1(struct torture_context *tctx, + struct smbcli_state *cli, int client) { extern int torture_seed; @@ -1903,9 +1904,9 @@ BOOL torture_ntdenytest1(struct torture_context *tctx, struct smbcli_state *cli, /* a denytest for ntcreatex */ -BOOL torture_ntdenytest2(struct torture_context *torture, - struct smbcli_state *cli1, - struct smbcli_state *cli2) +bool torture_ntdenytest2(struct torture_context *torture, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { return torture_ntdenytest(torture, cli1, cli2, 0); } @@ -1915,7 +1916,7 @@ BOOL torture_ntdenytest2(struct torture_context *torture, if (!NT_STATUS_EQUAL(status, correct)) { \ torture_comment(tctx, "(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -1923,21 +1924,21 @@ BOOL torture_ntdenytest2(struct torture_context *torture, if ((v) != (correct)) { \ torture_comment(tctx, "(%s) wrong value for %s 0x%x - should be 0x%x\n", \ __location__, #v, (int)(v), (int)correct); \ - ret = False; \ + ret = false; \ }} while (0) /* test sharing of handles with DENY_DOS on a single connection */ -BOOL torture_denydos_sharing(struct torture_context *tctx, - struct smbcli_state *cli) +bool torture_denydos_sharing(struct torture_context *tctx, + struct smbcli_state *cli) { union smb_open io; union smb_fileinfo finfo; const char *fname = "\\torture_denydos.txt"; NTSTATUS status; int fnum1 = -1, fnum2 = -1; - BOOL ret = True; + bool ret = true; union smb_setfileinfo sfinfo; TALLOC_CTX *mem_ctx; diff --git a/source4/torture/basic/dir.c b/source4/torture/basic/dir.c index 8b37188299..9a1ae2f744 100644 --- a/source4/torture/basic/dir.c +++ b/source4/torture/basic/dir.c @@ -33,12 +33,12 @@ static void list_fn(struct clilist_file_info *finfo, const char *name, void *sta /* test directory listing speed */ -BOOL torture_dirtest1(struct torture_context *tctx, - struct smbcli_state *cli) +bool torture_dirtest1(struct torture_context *tctx, + struct smbcli_state *cli) { int i; int fnum; - BOOL correct = True; + bool correct = true; extern int torture_numops; struct timeval tv; @@ -53,7 +53,7 @@ BOOL torture_dirtest1(struct torture_context *tctx, if (fnum == -1) { fprintf(stderr,"(%s) Failed to open %s\n", __location__, fname); - return False; + return false; } smbcli_close(cli->tree, fnum); free(fname); @@ -76,16 +76,16 @@ BOOL torture_dirtest1(struct torture_context *tctx, return correct; } -BOOL torture_dirtest2(struct torture_context *tctx, - struct smbcli_state *cli) +bool torture_dirtest2(struct torture_context *tctx, + struct smbcli_state *cli) { int i; int fnum, num_seen; - BOOL correct = True; + bool correct = true; extern int torture_entries; if (!torture_setup_dir(cli, "\\LISTDIR")) { - return False; + return false; } torture_comment(tctx, "Creating %d files\n", torture_entries); @@ -102,7 +102,7 @@ BOOL torture_dirtest2(struct torture_context *tctx, if (fnum == -1) { fprintf(stderr,"(%s) Failed to open %s, error=%s\n", __location__, fname, smbcli_errstr(cli->tree)); - return False; + return false; } free(fname); smbcli_close(cli->tree, fnum); @@ -113,7 +113,7 @@ BOOL torture_dirtest2(struct torture_context *tctx, if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) { fprintf(stderr,"(%s) Failed to open %s, error=%s\n", __location__, fname, smbcli_errstr(cli->tree)); - return False; + return false; } free(fname); } @@ -123,7 +123,7 @@ BOOL torture_dirtest2(struct torture_context *tctx, torture_comment(tctx, "num_seen = %d\n", num_seen ); /* We should see (torture_entries) each of files & directories + . and .. */ if (num_seen != (2*torture_entries)+2) { - correct = False; + correct = false; fprintf(stderr,"(%s) entry count mismatch, should be %d, was %d\n", __location__, (2*torture_entries)+2, num_seen); } @@ -135,7 +135,7 @@ BOOL torture_dirtest2(struct torture_context *tctx, num_seen = smbcli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL); torture_comment(tctx, "num_seen = %d\n", num_seen ); if (num_seen != torture_entries+2) { - correct = False; + correct = false; fprintf(stderr,"(%s) entry count mismatch, should be %d, was %d\n", __location__, torture_entries+2, num_seen); } @@ -143,7 +143,7 @@ BOOL torture_dirtest2(struct torture_context *tctx, num_seen = smbcli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL); torture_comment(tctx, "num_seen = %d\n", num_seen ); if (num_seen != torture_entries) { - correct = False; + correct = false; fprintf(stderr,"(%s) entry count mismatch, should be %d, was %d\n", __location__, torture_entries, num_seen); } @@ -152,7 +152,7 @@ BOOL torture_dirtest2(struct torture_context *tctx, if (smbcli_deltree(cli->tree, "\\LISTDIR") == -1) { fprintf(stderr,"(%s) Failed to deltree %s, error=%s\n", "\\LISTDIR", __location__, smbcli_errstr(cli->tree)); - return False; + return false; } #if 0 diff --git a/source4/torture/basic/disconnect.c b/source4/torture/basic/disconnect.c index e05e3ef082..cb77bfe984 100644 --- a/source4/torture/basic/disconnect.c +++ b/source4/torture/basic/disconnect.c @@ -33,13 +33,13 @@ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ talloc_free(cli); \ - return False; \ + return false; \ }} while (0) /* test disconnect after async open */ -static BOOL test_disconnect_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_disconnect_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; NTSTATUS status; @@ -71,14 +71,14 @@ static BOOL test_disconnect_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) talloc_free(cli); - return True; + return true; } /* test disconnect with timed lock */ -static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_lock io; NTSTATUS status; @@ -92,7 +92,7 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) O_RDWR | O_CREAT, DENY_NONE); if (fnum == -1) { printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } io.lockx.level = RAW_LOCK_LOCKX; @@ -118,7 +118,7 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) talloc_free(cli); - return True; + return true; } @@ -126,9 +126,9 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* basic testing of disconnects */ -BOOL torture_disconnect(struct torture_context *torture) +bool torture_disconnect(struct torture_context *torture) { - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx; int i; extern int torture_numops; @@ -137,25 +137,25 @@ BOOL torture_disconnect(struct torture_context *torture) mem_ctx = talloc_init("torture_raw_mux"); if (!torture_open_connection(&cli, 0)) { - return False; + return false; } if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } for (i=0;i<torture_numops;i++) { ret &= test_disconnect_lock(cli, mem_ctx); if (!torture_open_connection(&cli, 0)) { - return False; + return false; } ret &= test_disconnect_open(cli, mem_ctx); if (!torture_open_connection(&cli, 0)) { - return False; + return false; } - if (torture_setting_bool(torture, "samba3", False)) { + if (torture_setting_bool(torture, "samba3", false)) { /* * In Samba3 it might happen that the old smbd from * test_disconnect_lock is not scheduled before the diff --git a/source4/torture/basic/locking.c b/source4/torture/basic/locking.c index aa3168fb08..2e2585b976 100644 --- a/source4/torture/basic/locking.c +++ b/source4/torture/basic/locking.c @@ -48,7 +48,7 @@ static bool torture_locktest1(struct torture_context *tctx, uint_t lock_timeout; if (!torture_setup_dir(cli1, BASEDIR)) { - return False; + return false; } fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); @@ -71,14 +71,14 @@ static bool torture_locktest1(struct torture_context *tctx, "lock2 succeeded! This is a locking bug\n"); if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_LOCK_NOT_GRANTED)) return False; + NT_STATUS_LOCK_NOT_GRANTED)) return false; torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)), "lock2 succeeded! This is a locking bug\n"); if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_FILE_LOCK_CONFLICT)) return False; + NT_STATUS_FILE_LOCK_CONFLICT)) return false; torture_assert_ntstatus_ok(tctx, smbcli_lock(cli1->tree, fnum1, 5, 9, 0, WRITE_LOCK), @@ -90,21 +90,21 @@ static bool torture_locktest1(struct torture_context *tctx, "lock2 succeeded! This is a locking bug"); if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_LOCK_NOT_GRANTED)) return False; + NT_STATUS_LOCK_NOT_GRANTED)) return false; torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)), "lock2 succeeded! This is a locking bug"); if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_LOCK_NOT_GRANTED)) return False; + NT_STATUS_LOCK_NOT_GRANTED)) return false; torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)), "lock2 succeeded! This is a locking bug"); if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_FILE_LOCK_CONFLICT)) return False; + NT_STATUS_FILE_LOCK_CONFLICT)) return false; lock_timeout = (6 + (random() % 20)); torture_comment(tctx, "Testing lock timeout with timeout=%u\n", @@ -115,7 +115,7 @@ static bool torture_locktest1(struct torture_context *tctx, "lock3 succeeded! This is a locking bug\n"); if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_FILE_LOCK_CONFLICT)) return False; + NT_STATUS_FILE_LOCK_CONFLICT)) return false; t2 = time(NULL); if (t2 - t1 < 5) { @@ -133,7 +133,7 @@ static bool torture_locktest1(struct torture_context *tctx, "lock4 succeeded! This is a locking bug"); if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_FILE_LOCK_CONFLICT)) return False; + NT_STATUS_FILE_LOCK_CONFLICT)) return false; torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), talloc_asprintf(tctx, "close2 failed (%s)", smbcli_errstr(cli1->tree))); @@ -166,7 +166,7 @@ static bool torture_locktest2(struct torture_context *tctx, int fnum1, fnum2, fnum3; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } torture_comment(tctx, "Testing pid context\n"); @@ -202,21 +202,21 @@ static bool torture_locktest2(struct torture_context *tctx, "WRITE lock1 succeeded! This is a locking bug"); if (!check_error(__location__, cli, ERRDOS, ERRlock, - NT_STATUS_LOCK_NOT_GRANTED)) return False; + NT_STATUS_LOCK_NOT_GRANTED)) return false; torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, WRITE_LOCK)), "WRITE lock2 succeeded! This is a locking bug"); if (!check_error(__location__, cli, ERRDOS, ERRlock, - NT_STATUS_LOCK_NOT_GRANTED)) return False; + NT_STATUS_LOCK_NOT_GRANTED)) return false; torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, READ_LOCK)), "READ lock2 succeeded! This is a locking bug"); if (!check_error(__location__, cli, ERRDOS, ERRlock, - NT_STATUS_FILE_LOCK_CONFLICT)) return False; + NT_STATUS_FILE_LOCK_CONFLICT)) return false; torture_assert_ntstatus_ok(tctx, smbcli_lock(cli->tree, fnum1, 100, 4, 0, WRITE_LOCK), @@ -235,7 +235,7 @@ static bool torture_locktest2(struct torture_context *tctx, if (!check_error(__location__, cli, ERRDOS, ERRnotlocked, - NT_STATUS_RANGE_NOT_LOCKED)) return False; + NT_STATUS_RANGE_NOT_LOCKED)) return false; torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 0, 8)), @@ -243,13 +243,13 @@ static bool torture_locktest2(struct torture_context *tctx, if (!check_error(__location__, cli, ERRDOS, ERRnotlocked, - NT_STATUS_RANGE_NOT_LOCKED)) return False; + NT_STATUS_RANGE_NOT_LOCKED)) return false; torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum3, 0, 4, 0, WRITE_LOCK)), "lock3 succeeded! This is a locking bug"); - if (!check_error(__location__, cli, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; + if (!check_error(__location__, cli, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return false; cli->session->pid = 1; @@ -285,7 +285,7 @@ static bool torture_locktest3(struct torture_context *tctx, torture_comment(tctx, "Testing 32 bit offset ranges"); if (!torture_setup_dir(cli1, BASEDIR)) { - return False; + return false; } fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); @@ -362,7 +362,7 @@ static bool torture_locktest3(struct torture_context *tctx, } #define EXPECTED(ret, v) if ((ret) != (v)) { \ - torture_comment(tctx, "** "); correct = False; \ + torture_comment(tctx, "** "); correct = false; \ } /* @@ -374,12 +374,12 @@ static bool torture_locktest4(struct torture_context *tctx, { const char *fname = BASEDIR "\\lockt4.lck"; int fnum1, fnum2, f; - BOOL ret; + bool ret; uint8_t buf[1000]; - BOOL correct = True; + bool correct = true; if (!torture_setup_dir(cli1, BASEDIR)) { - return False; + return false; } fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); @@ -389,80 +389,80 @@ static bool torture_locktest4(struct torture_context *tctx, if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { torture_comment(tctx, "Failed to create file\n"); - correct = False; + correct = false; goto fail; } ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 2, 4, 0, WRITE_LOCK)); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "the same process %s set overlapping write locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 10, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 12, 4, 0, READ_LOCK)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the same process %s set overlapping read locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 20, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 22, 4, 0, WRITE_LOCK)); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "a different connection %s set overlapping write locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 30, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 32, 4, 0, READ_LOCK)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "a different connection %s set overlapping read locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 40, 4, 0, WRITE_LOCK))) && NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 42, 4, 0, WRITE_LOCK))); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "a different pid %s set overlapping write locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 50, 4, 0, READ_LOCK))) && NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 52, 4, 0, READ_LOCK))); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "a different pid %s set overlapping read locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the same process %s set the same read lock twice\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK)); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "the same process %s set the same write lock twice\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 80, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 80, 4, 0, WRITE_LOCK)); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "the same process %s overlay a read lock with a write lock\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 90, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 90, 4, 0, READ_LOCK)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the same process %s overlay a write lock with a read lock\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 100, 4, 0, WRITE_LOCK))) && NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 100, 4, 0, READ_LOCK))); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "a different pid %s overlay a write lock with a read lock\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 110, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 112, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 110, 6)); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "the same process %s coalesce read locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 120, 4, 0, WRITE_LOCK)) && (smbcli_read(cli2->tree, fnum2, buf, 120, 4) == 4); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "this server %s strict write locking\n", ret?"doesn't do":"does"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK)) && (smbcli_write(cli2->tree, fnum2, 0, buf, 130, 4) == 4); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "this server %s strict read locking\n", ret?"doesn't do":"does"); @@ -470,7 +470,7 @@ static bool torture_locktest4(struct torture_context *tctx, NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 140, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 140, 4)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 140, 4)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "this server %s do recursive read locking\n", ret?"does":"doesn't"); @@ -480,21 +480,21 @@ static bool torture_locktest4(struct torture_context *tctx, (smbcli_read(cli2->tree, fnum2, buf, 150, 4) == 4) && !(smbcli_write(cli2->tree, fnum2, 0, buf, 150, 4) == 4) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 150, 4)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "this server %s do recursive lock overlays\n", ret?"does":"doesn't"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 160, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 160, 4)) && (smbcli_write(cli2->tree, fnum2, 0, buf, 160, 4) == 4) && (smbcli_read(cli2->tree, fnum2, buf, 160, 4) == 4); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the same process %s remove a read lock using write locking\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 170, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 170, 4)) && (smbcli_write(cli2->tree, fnum2, 0, buf, 170, 4) == 4) && (smbcli_read(cli2->tree, fnum2, buf, 170, 4) == 4); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the same process %s remove a write lock using read locking\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 190, 4, 0, WRITE_LOCK)) && @@ -502,7 +502,7 @@ static bool torture_locktest4(struct torture_context *tctx, NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 190, 4)) && !(smbcli_write(cli2->tree, fnum2, 0, buf, 190, 4) == 4) && (smbcli_read(cli2->tree, fnum2, buf, 190, 4) == 4); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the same process %s remove the first lock first\n", ret?"does":"doesn't"); smbcli_close(cli1->tree, fnum1); @@ -516,7 +516,7 @@ static bool torture_locktest4(struct torture_context *tctx, NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK)); smbcli_close(cli1->tree, f); smbcli_close(cli1->tree, fnum1); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the server %s have the NT byte range lock bug\n", !ret?"does":"doesn't"); fail: @@ -535,12 +535,12 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state { const char *fname = BASEDIR "\\lockt5.lck"; int fnum1, fnum2, fnum3; - BOOL ret; + bool ret; uint8_t buf[1000]; - BOOL correct = True; + bool correct = true; if (!torture_setup_dir(cli1, BASEDIR)) { - return False; + return false; } fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); @@ -558,7 +558,7 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state smbcli_close(cli1->tree, fnum1); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "this server %s the NT locking bug\n", ret ? "doesn't have" : "has"); smbcli_close(cli1->tree, fnum1); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); @@ -566,11 +566,11 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 1, 1, 0, READ_LOCK)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the same process %s overlay a write with a read lock\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK)); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "a different processs %s get a read lock on the first process lock stack\n", ret?"can":"cannot"); @@ -578,7 +578,7 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state smbcli_unlock(cli2->tree, fnum2, 0, 4); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum3, 0, 4, 0, READ_LOCK)); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "the same processs on a different fnum %s get a read lock\n", ret?"can":"cannot"); @@ -589,7 +589,7 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the same process %s stack read locks\n", ret?"can":"cannot"); /* Unlock the first process lock, then check this was the WRITE lock that was @@ -598,7 +598,7 @@ static bool torture_locktest5(struct torture_context *tctx, struct smbcli_state ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) && NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the first unlock removes the %s lock\n", ret?"WRITE":"READ"); /* Unlock the process 2 lock. */ @@ -610,17 +610,17 @@ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "the same process %s unlock the stack of 4 locks\n", ret?"can":"cannot"); /* Ensure the next unlock fails. */ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)); - EXPECTED(ret, False); + EXPECTED(ret, false); torture_comment(tctx, "the same process %s count the lock stack\n", !ret?"can":"cannot"); /* Ensure connection 2 can get a write lock. */ ret = NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, WRITE_LOCK)); - EXPECTED(ret, True); + EXPECTED(ret, true); torture_comment(tctx, "a different processs %s get a write lock on the unlocked stack\n", ret?"can":"cannot"); @@ -644,7 +644,7 @@ static bool torture_locktest6(struct torture_context *tctx, NTSTATUS status; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } for (i=0;i<1;i++) { @@ -665,7 +665,7 @@ static bool torture_locktest6(struct torture_context *tctx, smbcli_unlink(cli->tree, fname[i]); } - return True; + return true; } static bool torture_locktest7(struct torture_context *tctx, @@ -676,7 +676,7 @@ static bool torture_locktest7(struct torture_context *tctx, int fnum2 = -1; size_t size; uint8_t buf[200]; - BOOL correct = False; + bool correct = false; torture_assert(tctx, torture_setup_dir(cli1, BASEDIR), talloc_asprintf(tctx, "Unable to set up %s", BASEDIR)); @@ -785,7 +785,7 @@ static bool torture_locktest7(struct torture_context *tctx, cli1->session->pid = 1; smbcli_unlock(cli1->tree, fnum1, 130, 4); - correct = True; + correct = true; fail: smbcli_close(cli1->tree, fnum1); @@ -795,10 +795,9 @@ fail: return correct; } -struct torture_suite *torture_base_locktest(void) +struct torture_suite *torture_base_locktest(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), - "LOCK"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCK"); torture_suite_add_2smb_test(suite, "LOCK1", torture_locktest1); torture_suite_add_1smb_test(suite, "LOCK2", torture_locktest2); torture_suite_add_2smb_test(suite, "LOCK3", torture_locktest3); diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 665360fc64..58d7098972 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -25,7 +25,6 @@ #include "lib/util/util_tdb.h" #include "libcli/libcli.h" #include "torture/util.h" -#include "pstring.h" static TDB_CONTEXT *tdb; @@ -33,11 +32,12 @@ static TDB_CONTEXT *tdb; static uint_t total, collisions, failures; -static BOOL test_one(struct smbcli_state *cli, const char *name) +static bool test_one(struct torture_context *tctx ,struct smbcli_state *cli, + const char *name) { int fnum; const char *shortname; - fstring name2; + const char *name2; NTSTATUS status; TDB_DATA data; @@ -46,37 +46,37 @@ static BOOL test_one(struct smbcli_state *cli, const char *name) fnum = smbcli_open(cli->tree, name, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { printf("open of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); - return False; + return false; } /* get the short name */ status = smbcli_qpathinfo_alt_name(cli->tree, name, &shortname); if (!NT_STATUS_IS_OK(status)) { printf("query altname of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); - return False; + return false; } - snprintf(name2, sizeof(name2), "\\mangle_test\\%s", shortname); + name2 = talloc_asprintf(tctx, "\\mangle_test\\%s", shortname); if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, name2))) { printf("unlink of %s (%s) failed (%s)\n", name2, name, smbcli_errstr(cli->tree)); - return False; + return false; } /* recreate by short name */ fnum = smbcli_open(cli->tree, name2, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { printf("open2 of %s failed (%s)\n", name2, smbcli_errstr(cli->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { printf("close of %s failed (%s)\n", name, smbcli_errstr(cli->tree)); - return False; + return false; } /* and unlink by long name */ @@ -85,7 +85,7 @@ static BOOL test_one(struct smbcli_state *cli, const char *name) name, name2, smbcli_errstr(cli->tree)); failures++; smbcli_unlink(cli->tree, name2); - return True; + return true; } /* see if the short name is already in the tdb */ @@ -108,22 +108,25 @@ static BOOL test_one(struct smbcli_state *cli, const char *name) tdb_store_bystring(tdb, shortname, namedata, TDB_REPLACE); } - return True; + return true; } -static void gen_name(char *name) +static char *gen_name(TALLOC_CTX *mem_ctx) { const char *chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-$~..."; uint_t max_idx = strlen(chars); uint_t len; int i; char *p; + char *name; - fstrcpy(name, "\\mangle_test\\"); - p = name + strlen(name); + name = talloc_strdup(mem_ctx, "\\mangle_test\\"); len = 1 + random() % NAME_LENGTH; + + name = talloc_realloc(mem_ctx, name, char, strlen(name) + len + 6); + p = name + strlen(name); for (i=0;i<len;i++) { p[i] = chars[random() % max_idx]; @@ -141,7 +144,7 @@ static void gen_name(char *name) } /* and a medium probability of a common lead string */ - if (random() % 10 == 0) { + if ((len > 5) && (random() % 10 == 0)) { strncpy(p, "ABCDE", 5); } @@ -152,11 +155,13 @@ static void gen_name(char *name) s[4] = 0; } } + + return name; } -BOOL torture_mangle(struct torture_context *torture, - struct smbcli_state *cli) +bool torture_mangle(struct torture_context *torture, + struct smbcli_state *cli) { extern int torture_numops; int i; @@ -165,21 +170,19 @@ BOOL torture_mangle(struct torture_context *torture, tdb = tdb_open(NULL, 100000, TDB_INTERNAL, 0, 0); if (!tdb) { printf("ERROR: Failed to open tdb\n"); - return False; + return false; } if (!torture_setup_dir(cli, "\\mangle_test")) { - return False; + return false; } for (i=0;i<torture_numops;i++) { - fstring name; - - ZERO_STRUCT(name); + char *name; - gen_name(name); + name = gen_name(torture); - if (!test_one(cli, name)) { + if (!test_one(torture, cli, name)) { break; } if (total && total % 100 == 0) { @@ -193,7 +196,7 @@ BOOL torture_mangle(struct torture_context *torture, smbcli_unlink(cli->tree, "\\mangle_test\\*"); if (NT_STATUS_IS_ERR(smbcli_rmdir(cli->tree, "\\mangle_test"))) { printf("ERROR: Failed to remove directory\n"); - return False; + return false; } printf("\nTotal collisions %u/%u - %.2f%% (%u failures)\n", diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c index d72e3ca1cd..f0d5ef5536 100644 --- a/source4/torture/basic/misc.c +++ b/source4/torture/basic/misc.c @@ -33,19 +33,20 @@ #include "torture/util.h" #include "libcli/smb_composite/smb_composite.h" #include "libcli/composite/composite.h" +#include "param/param.h" extern struct cli_credentials *cmdline_credentials; -static BOOL wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len) +static bool wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len) { while (NT_STATUS_IS_ERR(smbcli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK))) { - if (!check_error(__location__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; + if (!check_error(__location__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return false; } - return True; + return true; } -static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) +static bool rw_torture(struct torture_context *tctx, struct smbcli_state *c) { const char *lockfname = "\\torture.lck"; char *fname; @@ -54,7 +55,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) pid_t pid2, pid = getpid(); int i, j; uint8_t buf[1024]; - BOOL correct = True; + bool correct = true; fnum2 = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE); @@ -62,7 +63,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) fnum2 = smbcli_open(c->tree, lockfname, O_RDWR, DENY_NONE); if (fnum2 == -1) { torture_comment(tctx, "open of %s failed (%s)\n", lockfname, smbcli_errstr(c->tree)); - return False; + return false; } generate_random_buffer(buf, sizeof(buf)); @@ -78,19 +79,19 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) asprintf(&fname, "\\torture.%u", n); if (!wait_lock(c, fnum2, n*sizeof(int), sizeof(int))) { - return False; + return false; } fnum = smbcli_open(c->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL); if (fnum == -1) { torture_comment(tctx, "open failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; break; } if (smbcli_write(c->tree, fnum, 0, &pid, 0, sizeof(pid)) != sizeof(pid)) { torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } for (j=0;j<50;j++) { @@ -98,7 +99,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) sizeof(pid)+(j*sizeof(buf)), sizeof(buf)) != sizeof(buf)) { torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } } @@ -106,27 +107,27 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) if (smbcli_read(c->tree, fnum, &pid2, 0, sizeof(pid)) != sizeof(pid)) { torture_comment(tctx, "read failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } if (pid2 != pid) { torture_comment(tctx, "data corruption!\n"); - correct = False; + correct = false; } if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) { torture_comment(tctx, "close failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } if (NT_STATUS_IS_ERR(smbcli_unlink(c->tree, fname))) { torture_comment(tctx, "unlink failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } if (NT_STATUS_IS_ERR(smbcli_unlock(c->tree, fnum2, n*sizeof(int), sizeof(int)))) { torture_comment(tctx, "unlock failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; + correct = false; } free(fname); } @@ -139,7 +140,7 @@ static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) return correct; } -BOOL run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dummy) +bool run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dummy) { return rw_torture(tctx, cli); } @@ -148,7 +149,7 @@ BOOL run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dum /* see how many RPC pipes we can open at once */ -BOOL run_pipe_number(struct torture_context *tctx, +bool run_pipe_number(struct torture_context *tctx, struct smbcli_state *cli1) { const char *pipe_name = "\\WKSSVC"; @@ -171,7 +172,7 @@ BOOL run_pipe_number(struct torture_context *tctx, } torture_comment(tctx, "pipe_number test - we can open %d %s pipes.\n", num_pipes, pipe_name ); - return True; + return true; } @@ -182,7 +183,7 @@ BOOL run_pipe_number(struct torture_context *tctx, used for testing performance when there are N idle users already connected */ -BOOL torture_holdcon(struct torture_context *tctx) +bool torture_holdcon(struct torture_context *tctx) { int i; struct smbcli_state **cli; @@ -194,7 +195,7 @@ BOOL torture_holdcon(struct torture_context *tctx) for (i=0;i<torture_numops;i++) { if (!torture_open_connection(&cli[i], i)) { - return False; + return false; } if (torture_setting_bool(tctx, "progress", true)) { torture_comment(tctx, "opened %d connections\r", i); @@ -227,34 +228,34 @@ BOOL torture_holdcon(struct torture_context *tctx) fflush(stdout); } - return True; + return true; } /* test how many open files this server supports on the one socket */ -BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int dummy) +bool run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int dummy) { #define MAXFID_TEMPLATE "\\maxfid\\fid%d\\maxfid.%d.%d" char *fname; int fnums[0x11000], i; int retries=4, maxfid; - BOOL correct = True; + bool correct = true; if (retries <= 0) { torture_comment(tctx, "failed to connect\n"); - return False; + return false; } if (smbcli_deltree(cli->tree, "\\maxfid") == -1) { torture_comment(tctx, "Failed to deltree \\maxfid - %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\maxfid"))) { torture_comment(tctx, "Failed to mkdir \\maxfid, error=%s\n", smbcli_errstr(cli->tree)); - return False; + return false; } torture_comment(tctx, "Testing maximum number of open files\n"); @@ -265,7 +266,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) { torture_comment(tctx, "Failed to mkdir %s, error=%s\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } free(fname); } @@ -298,7 +299,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { torture_comment(tctx, "unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - correct = False; + correct = false; } free(fname); @@ -309,7 +310,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { torture_comment(tctx, "unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - correct = False; + correct = false; } free(fname); @@ -323,12 +324,12 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int if (smbcli_deltree(cli->tree, "\\maxfid") == -1) { torture_comment(tctx, "Failed to deltree \\maxfid - %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } torture_comment(tctx, "maxfid test finished\n"); if (!torture_close_connection(cli)) { - correct = False; + correct = false; } return correct; #undef MAXFID_TEMPLATE @@ -339,7 +340,7 @@ BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int /* sees what IOCTLs are supported */ -BOOL torture_ioctl_test(struct torture_context *tctx, +bool torture_ioctl_test(struct torture_context *tctx, struct smbcli_state *cli) { uint16_t device, function; @@ -356,7 +357,7 @@ BOOL torture_ioctl_test(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } parms.ioctl.level = RAW_IOCTL_IOCTL; @@ -378,7 +379,7 @@ BOOL torture_ioctl_test(struct torture_context *tctx, } } - return True; + return true; } static void benchrw_callback(struct smbcli_request *req); @@ -441,7 +442,7 @@ static int init_benchrw_params(struct torture_context *tctx, lpar->writeratio = torture_setting_int(tctx, "writeratio",5); lpar->num_parallel_requests = torture_setting_int( tctx, "parallel_requests", 5); - lpar->workgroup = lp_workgroup(); + lpar->workgroup = lp_workgroup(global_loadparm); p = torture_setting_string(tctx, "unclist", NULL); if (p) { @@ -581,7 +582,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx, rd.readx.in.maxcnt = rd.readx.in.mincnt; rd.readx.in.remaining = 0 ; rd.readx.out.data = state->buffer; - rd.readx.in.read_for_execute = False; + rd.readx.in.read_for_execute = false; if(state->readcnt < state->lp_params->writeblocks){ state->readcnt++; }else{ @@ -818,13 +819,13 @@ static struct composite_context *torture_connect_async( smb->in.called_name = strupper_talloc(mem_ctx, host); smb->in.service_type=NULL; smb->in.credentials=cmdline_credentials; - smb->in.fallback_to_anonymous=False; + smb->in.fallback_to_anonymous=false; smb->in.workgroup=workgroup; return smb_composite_connect_send(smb,mem_ctx,ev); } -BOOL run_benchrw(struct torture_context *tctx) +bool run_benchrw(struct torture_context *tctx) { struct smb_composite_connect *smb_con; const char *fname = "\\rwtest.dat"; @@ -836,7 +837,7 @@ BOOL run_benchrw(struct torture_context *tctx) struct params lpparams; union smb_mkdir parms; int finished = 0; - BOOL success=True; + bool success=true; int torture_nprocs = torture_setting_int(tctx, "nprocs", 4); torture_comment(tctx, "Start BENCH-READWRITE num_ops=%d " @@ -910,7 +911,7 @@ BOOL run_benchrw(struct torture_context *tctx) /* error occured , finish */ case ERROR: finished++; - success=False; + success=false; break; /* cleanup , close connection */ case CLEANUP: diff --git a/source4/torture/basic/properties.c b/source4/torture/basic/properties.c index 6a8e84cc2f..1825dff993 100644 --- a/source4/torture/basic/properties.c +++ b/source4/torture/basic/properties.c @@ -88,10 +88,10 @@ static void show_bits(const struct bitmapping *bm, uint32_t value) /* print out server properties */ -BOOL torture_test_properties(struct torture_context *torture, - struct smbcli_state *cli) +bool torture_test_properties(struct torture_context *torture, + struct smbcli_state *cli) { - BOOL correct = True; + bool correct = true; union smb_fsinfo fs; NTSTATUS status; @@ -103,7 +103,7 @@ BOOL torture_test_properties(struct torture_context *torture, status = smb_raw_fsinfo(cli->tree, cli, &fs); if (!NT_STATUS_IS_OK(status)) { d_printf("qfsinfo failed - %s\n", nt_errstr(status)); - correct = False; + correct = false; } else { d_printf("Filesystem attributes: 0x%08x\n", fs.attribute_info.out.fs_attr); diff --git a/source4/torture/basic/rename.c b/source4/torture/basic/rename.c index 572048e0ea..12fd5e1c99 100644 --- a/source4/torture/basic/rename.c +++ b/source4/torture/basic/rename.c @@ -27,8 +27,8 @@ /* Test rename on files open with share delete and no share delete. */ -BOOL torture_test_rename(struct torture_context *tctx, - struct smbcli_state *cli1) +bool torture_test_rename(struct torture_context *tctx, + struct smbcli_state *cli1) { const char *fname = "\\test.txt"; const char *fname1 = "\\test1.txt"; diff --git a/source4/torture/basic/scanner.c b/source4/torture/basic/scanner.c index 0a1cfc2e01..dd596c9ee3 100644 --- a/source4/torture/basic/scanner.c +++ b/source4/torture/basic/scanner.c @@ -122,7 +122,7 @@ static NTSTATUS try_trans2_len(struct smbcli_state *cli, /**************************************************************************** check whether a trans2 opnum exists at all ****************************************************************************/ -static BOOL trans2_op_exists(struct smbcli_state *cli, int op) +static bool trans2_op_exists(struct smbcli_state *cli, int op) { int data_len = 0; int param_len = 0; @@ -146,17 +146,17 @@ static BOOL trans2_op_exists(struct smbcli_state *cli, int op) status2 = try_trans2(cli, op, param, data, param_len, data_len, &rparam_len, &rdata_len); - if (NT_STATUS_EQUAL(status1, status2)) return False; + if (NT_STATUS_EQUAL(status1, status2)) return false; printf("Found op %d (status=%s)\n", op, nt_errstr(status2)); - return True; + return true; } /**************************************************************************** check for existance of a trans2 call ****************************************************************************/ -static BOOL scan_trans2(struct smbcli_state *cli, int op, int level, +static bool scan_trans2(struct smbcli_state *cli, int op, int level, int fnum, int dnum, int qfnum, const char *fname) { int data_len = 0; @@ -173,7 +173,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level, SSVAL(param, 0, level); status = try_trans2_len(cli, "void", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try with a file descriptor */ param_len = 6; @@ -182,7 +182,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level, SSVAL(param, 4, 0); status = try_trans2_len(cli, "fnum", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try with a quota file descriptor */ param_len = 6; @@ -191,7 +191,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level, SSVAL(param, 4, 0); status = try_trans2_len(cli, "qfnum", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try with a notify style */ param_len = 6; @@ -200,7 +200,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level, SSVAL(param, 4, level); status = try_trans2_len(cli, "notify", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try with a file name */ param_len = 6; @@ -211,7 +211,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level, status = try_trans2_len(cli, "fname", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try with a new file name */ param_len = 6; @@ -224,7 +224,7 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level, &rparam_len, &rdata_len); smbcli_unlink(cli->tree, "\\newfile.dat"); smbcli_rmdir(cli->tree, "\\newfile.dat"); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try dfs style */ smbcli_mkdir(cli->tree, "\\testdir"); @@ -235,13 +235,13 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level, status = try_trans2_len(cli, "dfs", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); smbcli_rmdir(cli->tree, "\\testdir"); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; - return False; + return false; } -BOOL torture_trans2_scan(struct torture_context *torture, +bool torture_trans2_scan(struct torture_context *torture, struct smbcli_state *cli) { int op, level; @@ -292,7 +292,7 @@ BOOL torture_trans2_scan(struct torture_context *torture, } } - return True; + return true; } @@ -396,7 +396,7 @@ static NTSTATUS try_nttrans_len(struct smbcli_state *cli, /**************************************************************************** check for existance of a nttrans call ****************************************************************************/ -static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level, +static bool scan_nttrans(struct smbcli_state *cli, int op, int level, int fnum, int dnum, const char *fname) { int data_len = 0; @@ -413,7 +413,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level, SSVAL(param, 0, level); status = try_nttrans_len(cli, "void", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try with a file descriptor */ param_len = 6; @@ -422,7 +422,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level, SSVAL(param, 4, 0); status = try_nttrans_len(cli, "fnum", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try with a notify style */ @@ -432,7 +432,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level, SSVAL(param, 4, level); status = try_nttrans_len(cli, "notify", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try with a file name */ param_len = 6; @@ -443,7 +443,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level, status = try_nttrans_len(cli, "fname", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try with a new file name */ param_len = 6; @@ -456,7 +456,7 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level, &rparam_len, &rdata_len); smbcli_unlink(cli->tree, "\\newfile.dat"); smbcli_rmdir(cli->tree, "\\newfile.dat"); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; /* try dfs style */ smbcli_mkdir(cli->tree, "\\testdir"); @@ -467,14 +467,14 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level, status = try_nttrans_len(cli, "dfs", op, level, param, data, param_len, &data_len, &rparam_len, &rdata_len); smbcli_rmdir(cli->tree, "\\testdir"); - if (NT_STATUS_IS_OK(status)) return True; + if (NT_STATUS_IS_OK(status)) return true; - return False; + return false; } -BOOL torture_nttrans_scan(struct torture_context *torture, - struct smbcli_state *cli) +bool torture_nttrans_scan(struct torture_context *torture, + struct smbcli_state *cli) { int op, level; const char *fname = "\\scanner.dat"; @@ -499,15 +499,13 @@ BOOL torture_nttrans_scan(struct torture_context *torture, } } - torture_close_connection(cli); - printf("nttrans scan finished\n"); - return True; + return true; } /* scan for valid base SMB requests */ -BOOL torture_smb_scan(struct torture_context *torture) +bool torture_smb_scan(struct torture_context *torture) { static struct smbcli_state *cli; int op; @@ -518,7 +516,7 @@ BOOL torture_smb_scan(struct torture_context *torture) if (op == SMBreadbraw) continue; if (!torture_open_connection(&cli, 0)) { - return False; + return false; } req = smbcli_request_setup(cli->tree, op, 0, 0); @@ -553,5 +551,5 @@ BOOL torture_smb_scan(struct torture_context *torture) printf("smb scan finished\n"); - return True; + return true; } diff --git a/source4/torture/basic/secleak.c b/source4/torture/basic/secleak.c index cb6cc84152..3d4aeea956 100644 --- a/source4/torture/basic/secleak.c +++ b/source4/torture/basic/secleak.c @@ -27,20 +27,21 @@ #include "system/time.h" #include "libcli/smb_composite/smb_composite.h" #include "auth/credentials/credentials.h" +#include "param/param.h" -static BOOL try_failed_login(struct smbcli_state *cli) +static bool try_failed_login(struct smbcli_state *cli) { NTSTATUS status; struct smb_composite_sesssetup setup; struct smbcli_session *session; - session = smbcli_session_init(cli->transport, cli, False); + session = smbcli_session_init(cli->transport, cli, false); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; - setup.in.workgroup = lp_workgroup(); + setup.in.workgroup = lp_workgroup(global_loadparm); setup.in.credentials = cli_credentials_init(session); - cli_credentials_set_conf(setup.in.credentials); + cli_credentials_set_conf(setup.in.credentials, global_loadparm); cli_credentials_set_domain(setup.in.credentials, "INVALID-DOMAIN", CRED_SPECIFIED); cli_credentials_set_username(setup.in.credentials, "INVALID-USERNAME", CRED_SPECIFIED); cli_credentials_set_password(setup.in.credentials, "INVALID-PASSWORD", CRED_SPECIFIED); @@ -49,23 +50,23 @@ static BOOL try_failed_login(struct smbcli_state *cli) talloc_free(session); if (NT_STATUS_IS_OK(status)) { printf("Allowed session setup with invalid credentials?!\n"); - return False; + return false; } - return True; + return true; } -BOOL torture_sec_leak(struct torture_context *tctx, struct smbcli_state *cli) +bool torture_sec_leak(struct torture_context *tctx, struct smbcli_state *cli) { time_t t1 = time(NULL); int timelimit = torture_setting_int(tctx, "timelimit", 20); while (time(NULL) < t1+timelimit) { if (!try_failed_login(cli)) { - return False; + return false; } talloc_report(NULL, stdout); } - return True; + return true; } diff --git a/source4/torture/basic/unlink.c b/source4/torture/basic/unlink.c index 60d5a1554d..9e13021d20 100644 --- a/source4/torture/basic/unlink.c +++ b/source4/torture/basic/unlink.c @@ -33,11 +33,11 @@ 1) the server does not allow an unlink on a file that is open */ -BOOL torture_unlinktest(struct torture_context *tctx, struct smbcli_state *cli) +bool torture_unlinktest(struct torture_context *tctx, struct smbcli_state *cli) { const char *fname = BASEDIR "\\unlink.tst"; int fnum; - BOOL correct = True; + bool correct = true; union smb_open io; NTSTATUS status; diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c index 52babe4d53..82511aa8f9 100644 --- a/source4/torture/basic/utable.c +++ b/source4/torture/basic/utable.c @@ -166,7 +166,7 @@ bool torture_casetable(struct torture_context *tctx, torture_comment(tctx, "too many chars match?? size=%d c=0x%04x\n", (int)size, c); smbcli_close(cli->tree, fnum); - return False; + return false; } smbcli_read(cli->tree, fnum, c2, 0, size); diff --git a/source4/torture/config.mk b/source4/torture/config.mk index fc85cc160a..02188d8560 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -96,6 +96,7 @@ PRIVATE_DEPENDENCIES = \ ################################# include smb2/config.mk +include winbind/config.mk [SUBSYSTEM::TORTURE_NDR] PRIVATE_PROTO_HEADER = ndr/proto.h @@ -128,8 +129,10 @@ OBJ_FILES = \ rpc/drsuapi_cracknames.o \ rpc/dssync.o \ rpc/spoolss.o \ + rpc/spoolss_notify.o \ rpc/unixinfo.o \ rpc/samr.o \ + rpc/samr_accessmask.o \ rpc/wkssvc.o \ rpc/srvsvc.o \ rpc/svcctl.o \ @@ -164,7 +167,8 @@ PRIVATE_DEPENDENCIES = \ RPC_NDR_LSA RPC_NDR_EPMAPPER RPC_NDR_DFS RPC_NDR_SPOOLSS \ RPC_NDR_SRVSVC RPC_NDR_WKSSVC RPC_NDR_ROT RPC_NDR_DSSETUP \ RPC_NDR_REMACT RPC_NDR_OXIDRESOLVER WB_HELPER LIBSAMBA-NET \ - LIBCLI_AUTH POPT_CREDENTIALS TORTURE_LDAP TORTURE_UTIL TORTURE_RAP + LIBCLI_AUTH POPT_CREDENTIALS TORTURE_LDAP TORTURE_UTIL TORTURE_RAP \ + dcerpc_server service process_model ################################# # Start SUBSYSTEM TORTURE_RAP @@ -273,9 +277,11 @@ PRIVATE_PROTO_HEADER = \ libnet/proto.h OBJ_FILES = \ libnet/libnet.o \ + libnet/utils.o \ libnet/userinfo.o \ libnet/userman.o \ libnet/groupinfo.o \ + libnet/groupman.o \ libnet/domain.o \ libnet/libnet_lookup.o \ libnet/libnet_user.o \ diff --git a/source4/torture/gentest.c b/source4/torture/gentest.c index d232f49016..79eb7eb0e9 100644 --- a/source4/torture/gentest.c +++ b/source4/torture/gentest.c @@ -26,29 +26,31 @@ #include "librpc/gen_ndr/security.h" #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" +#include "param/param.h" +#include "dynconfig.h" #define NSERVERS 2 #define NINSTANCES 2 /* global options */ static struct gentest_options { - BOOL showall; - BOOL analyze; - BOOL analyze_always; - BOOL analyze_continuous; + bool showall; + bool analyze; + bool analyze_always; + bool analyze_continuous; uint_t max_open_handles; uint_t seed; uint_t numops; - BOOL use_oplocks; + bool use_oplocks; char **ignore_patterns; const char *seeds_file; - BOOL use_preset_seeds; - BOOL fast_reconnect; + bool use_preset_seeds; + bool fast_reconnect; } options; /* mapping between open handles on the server and local handles */ static struct { - BOOL active; + bool active; uint_t instance; uint_t server_fnum[NSERVERS]; const char *name; @@ -67,17 +69,17 @@ static struct { /* the seeds and flags for each operation */ static struct { uint_t seed; - BOOL disabled; + bool disabled; } *op_parms; /* oplock break info */ static struct { - BOOL got_break; + bool got_break; uint16_t fnum; uint16_t handle; uint8_t level; - BOOL do_close; + bool do_close; } oplocks[NSERVERS][NINSTANCES]; /* change notify reply info */ @@ -100,32 +102,32 @@ static struct { #define BAD_HANDLE 0xFFFE -static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private); +static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private); static void idle_func(struct smbcli_transport *transport, void *private); /* check if a string should be ignored. This is used as the basis for all error ignore settings */ -static BOOL ignore_pattern(const char *str) +static bool ignore_pattern(const char *str) { int i; - if (!options.ignore_patterns) return False; + if (!options.ignore_patterns) return false; for (i=0;options.ignore_patterns[i];i++) { if (strcmp(options.ignore_patterns[i], str) == 0 || gen_fnmatch(options.ignore_patterns[i], str) == 0) { DEBUG(2,("Ignoring '%s'\n", str)); - return True; + return true; } } - return False; + return false; } /***************************************************** connect to the servers *******************************************************/ -static BOOL connect_servers_fast(void) +static bool connect_servers_fast(void) { int h, i; @@ -135,13 +137,13 @@ static BOOL connect_servers_fast(void) for (i=0;i<NSERVERS;i++) { if (NT_STATUS_IS_ERR((smbcli_close(servers[i].cli[open_handles[h].instance]->tree, open_handles[h].server_fnum[i])))) { - return False; + return false; } - open_handles[h].active = False; + open_handles[h].active = false; } } - return True; + return true; } @@ -150,13 +152,13 @@ static BOOL connect_servers_fast(void) /***************************************************** connect to the servers *******************************************************/ -static BOOL connect_servers(void) +static bool connect_servers(void) { int i, j; if (options.fast_reconnect && servers[0].cli[0]) { if (connect_servers_fast()) { - return True; + return true; } } @@ -189,7 +191,7 @@ static BOOL connect_servers(void) printf("Failed to connect to \\\\%s\\%s - %s\n", servers[i].server_name, servers[i].share_name, nt_errstr(status)); - return False; + return false; } smbcli_oplock_handler(servers[i].cli[j]->transport, oplock_handler, NULL); @@ -197,7 +199,7 @@ static BOOL connect_servers(void) } } - return True; + return true; } /* @@ -254,7 +256,7 @@ static void gen_add_handle(int instance, const char *name, uint16_t fnums[NSERVE for (i=0;i<NSERVERS;i++) { open_handles[h].server_fnum[i] = fnums[i]; open_handles[h].instance = instance; - open_handles[h].active = True; + open_handles[h].active = true; open_handles[h].name = name; } num_open_handles++; @@ -274,7 +276,7 @@ static void gen_remove_handle(int instance, uint16_t fnums[NSERVERS]) for (h=0;h<options.max_open_handles;h++) { if (instance == open_handles[h].instance && open_handles[h].server_fnum[0] == fnums[0]) { - open_handles[h].active = False; + open_handles[h].active = false; num_open_handles--; printf("CLOSE num_open_handles=%d h=%d s1=0x%x s2=0x%x (%s)\n", num_open_handles, h, @@ -288,9 +290,9 @@ static void gen_remove_handle(int instance, uint16_t fnums[NSERVERS]) } /* - return True with 'chance' probability as a percentage + return true with 'chance' probability as a percentage */ -static BOOL gen_chance(uint_t chance) +static bool gen_chance(uint_t chance) { return ((random() % 100) <= chance); } @@ -472,7 +474,7 @@ static uint32_t gen_bits_mask2(uint32_t mask1, uint32_t mask2) /* generate a boolean */ -static BOOL gen_bool(void) +static bool gen_bool(void) { return gen_bits_mask2(0x1, 0xFF); } @@ -725,11 +727,11 @@ static void oplock_handler_close_recv(struct smbcli_request *req) /* the oplock handler will either ack the break or close the file */ -static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private) +static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private) { union smb_close io; int i, j; - BOOL do_close; + bool do_close; struct smbcli_tree *tree = NULL; struct smbcli_request *req; @@ -740,7 +742,7 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin for (j=0;j<NINSTANCES;j++) { if (transport == servers[i].cli[j]->transport && tid == servers[i].cli[j]->tree->tid) { - oplocks[i][j].got_break = True; + oplocks[i][j].got_break = true; oplocks[i][j].fnum = fnum; oplocks[i][j].handle = fnum_to_handle(i, j, fnum); oplocks[i][j].level = level; @@ -752,7 +754,7 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin if (!tree) { printf("Oplock break not for one of our trees!?\n"); - return False; + return false; } if (!do_close) { @@ -769,13 +771,13 @@ static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, uin if (req == NULL) { printf("WARNING: close failed in oplock_handler_close\n"); - return False; + return false; } req->async.fn = oplock_handler_close_recv; req->async.private = NULL; - return True; + return true; } @@ -802,19 +804,19 @@ static void idle_func(struct smbcli_transport *transport, void *private) /* compare NTSTATUS, using checking ignored patterns */ -static BOOL compare_status(NTSTATUS status1, NTSTATUS status2) +static bool compare_status(NTSTATUS status1, NTSTATUS status2) { - if (NT_STATUS_EQUAL(status1, status2)) return True; + if (NT_STATUS_EQUAL(status1, status2)) return true; /* one code being an error and the other OK is always an error */ - if (NT_STATUS_IS_OK(status1) || NT_STATUS_IS_OK(status2)) return False; + if (NT_STATUS_IS_OK(status1) || NT_STATUS_IS_OK(status2)) return false; /* if we are ignoring one of the status codes then consider this a match */ if (ignore_pattern(nt_errstr(status1)) || ignore_pattern(nt_errstr(status2))) { - return True; + return true; } - return False; + return false; } @@ -837,7 +839,7 @@ static void check_pending(void) /* check that the same oplock breaks have been received by all instances */ -static BOOL check_oplocks(const char *call) +static bool check_oplocks(const char *call) { int i, j; int tries = 0; @@ -858,7 +860,7 @@ again: oplocks[i][j].got_break, oplocks[i][j].handle, oplocks[i][j].level); - return False; + return false; } } } @@ -875,14 +877,14 @@ again: break; } } - return True; + return true; } /* check that the same change notify info has been received by all instances */ -static BOOL check_notifies(const char *call) +static bool check_notifies(const char *call) { int i, j; int tries = 0; @@ -900,7 +902,7 @@ again: printf("Notify count inconsistent %d %d\n", notifies[0][j].notify_count, notifies[i][j].notify_count); - return False; + return false; } if (notifies[0][j].notify_count == 0) continue; @@ -910,7 +912,7 @@ again: printf("Notify status mismatch - %s - %s\n", nt_errstr(notifies[0][j].status), nt_errstr(notifies[i][j].status)); - return False; + return false; } if (!NT_STATUS_IS_OK(notifies[0][j].status)) { @@ -926,21 +928,21 @@ again: printf("Notify action %d inconsistent %d %d\n", n, not1.nttrans.out.changes[n].action, not2.nttrans.out.changes[n].action); - return False; + return false; } if (strcmp(not1.nttrans.out.changes[n].name.s, not2.nttrans.out.changes[n].name.s)) { printf("Notify name %d inconsistent %s %s\n", n, not1.nttrans.out.changes[n].name.s, not2.nttrans.out.changes[n].name.s); - return False; + return false; } if (not1.nttrans.out.changes[n].name.private_length != not2.nttrans.out.changes[n].name.private_length) { printf("Notify name length %d inconsistent %d %d\n", n, not1.nttrans.out.changes[n].name.private_length, not2.nttrans.out.changes[n].name.private_length); - return False; + return false; } } } @@ -948,7 +950,7 @@ again: ZERO_STRUCT(notifies); - return True; + return true; } @@ -972,13 +974,13 @@ again: if (!compare_status(status[i], status[0])) { \ printf("status different in %s - %s %s\n", #call, \ nt_errstr(status[0]), nt_errstr(status[i])); \ - return False; \ + return false; \ } \ } \ - if (!check_oplocks(#call)) return False; \ - if (!check_notifies(#call)) return False; \ + if (!check_oplocks(#call)) return false; \ + if (!check_notifies(#call)) return false; \ if (!NT_STATUS_IS_OK(status[0])) { \ - return True; \ + return true; \ } \ } while(0) @@ -1011,19 +1013,19 @@ again: if (parm[0].field != parm[1].field && !ignore_pattern(#field)) { \ printf("Mismatch in %s - 0x%x 0x%x\n", #field, \ (int)parm[0].field, (int)parm[1].field); \ - return False; \ + return false; \ } \ } while(0) #define CHECK_WSTR_EQUAL(field) do { \ if ((!parm[0].field.s && parm[1].field.s) || (parm[0].field.s && !parm[1].field.s)) { \ printf("%s is NULL!\n", #field); \ - return False; \ + return false; \ } \ if (parm[0].field.s && strcmp(parm[0].field.s, parm[1].field.s) != 0 && !ignore_pattern(#field)) { \ printf("Mismatch in %s - %s %s\n", #field, \ parm[0].field.s, parm[1].field.s); \ - return False; \ + return false; \ } \ CHECK_EQUAL(field.private_length); \ } while(0) @@ -1031,7 +1033,7 @@ again: #define CHECK_BLOB_EQUAL(field) do { \ if (memcmp(parm[0].field.data, parm[1].field.data, parm[0].field.length) != 0 && !ignore_pattern(#field)) { \ printf("Mismatch in %s\n", #field); \ - return False; \ + return false; \ } \ CHECK_EQUAL(field.length); \ } while(0) @@ -1041,7 +1043,7 @@ again: !ignore_pattern(#field)) { \ printf("Mismatch in %s - 0x%x 0x%x\n", #field, \ (int)parm[0].field, (int)parm[1].field); \ - return False; \ + return false; \ } \ } while(0) @@ -1052,14 +1054,14 @@ again: printf("Mismatch in %s - 0x%x 0x%x\n", #field, \ (int)nt_time_to_unix(parm[0].field), \ (int)nt_time_to_unix(parm[1].field)); \ - return False; \ + return false; \ } \ } while(0) /* generate openx operations */ -static BOOL handler_openx(int instance) +static bool handler_openx(int instance) { union smb_open parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1097,14 +1099,14 @@ static BOOL handler_openx(int instance) /* open creates a new file handle */ ADD_HANDLE(parm[0].openx.in.fname, openx.out.file.fnum); - return True; + return true; } /* generate open operations */ -static BOOL handler_open(int instance) +static bool handler_open(int instance) { union smb_open parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1131,14 +1133,14 @@ static BOOL handler_open(int instance) /* open creates a new file handle */ ADD_HANDLE(parm[0].openold.in.fname, openold.out.file.fnum); - return True; + return true; } /* generate ntcreatex operations */ -static BOOL handler_ntcreatex(int instance) +static bool handler_ntcreatex(int instance) { union smb_open parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1184,13 +1186,13 @@ static BOOL handler_ntcreatex(int instance) /* ntcreatex creates a new file handle */ ADD_HANDLE(parm[0].ntcreatex.in.fname, ntcreatex.out.file.fnum); - return True; + return true; } /* generate close operations */ -static BOOL handler_close(int instance) +static bool handler_close(int instance) { union smb_close parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1205,13 +1207,13 @@ static BOOL handler_close(int instance) REMOVE_HANDLE(close.in.file.fnum); - return True; + return true; } /* generate unlink operations */ -static BOOL handler_unlink(int instance) +static bool handler_unlink(int instance) { union smb_unlink parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1222,13 +1224,13 @@ static BOOL handler_unlink(int instance) GEN_COPY_PARM; GEN_CALL(smb_raw_unlink(tree, &parm[i])); - return True; + return true; } /* generate chkpath operations */ -static BOOL handler_chkpath(int instance) +static bool handler_chkpath(int instance) { union smb_chkpath parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1238,13 +1240,13 @@ static BOOL handler_chkpath(int instance) GEN_COPY_PARM; GEN_CALL(smb_raw_chkpath(tree, &parm[i])); - return True; + return true; } /* generate mkdir operations */ -static BOOL handler_mkdir(int instance) +static bool handler_mkdir(int instance) { union smb_mkdir parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1255,13 +1257,13 @@ static BOOL handler_mkdir(int instance) GEN_COPY_PARM; GEN_CALL(smb_raw_mkdir(tree, &parm[i])); - return True; + return true; } /* generate rmdir operations */ -static BOOL handler_rmdir(int instance) +static bool handler_rmdir(int instance) { struct smb_rmdir parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1271,13 +1273,13 @@ static BOOL handler_rmdir(int instance) GEN_COPY_PARM; GEN_CALL(smb_raw_rmdir(tree, &parm[i])); - return True; + return true; } /* generate rename operations */ -static BOOL handler_rename(int instance) +static bool handler_rename(int instance) { union smb_rename parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1290,13 +1292,13 @@ static BOOL handler_rename(int instance) GEN_COPY_PARM; GEN_CALL(smb_raw_rename(tree, &parm[i])); - return True; + return true; } /* generate ntrename operations */ -static BOOL handler_ntrename(int instance) +static bool handler_ntrename(int instance) { union smb_rename parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1311,14 +1313,14 @@ static BOOL handler_ntrename(int instance) GEN_COPY_PARM; GEN_CALL(smb_raw_rename(tree, &parm[i])); - return True; + return true; } /* generate seek operations */ -static BOOL handler_seek(int instance) +static bool handler_seek(int instance) { union smb_seek parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1333,14 +1335,14 @@ static BOOL handler_seek(int instance) CHECK_EQUAL(lseek.out.offset); - return True; + return true; } /* generate readx operations */ -static BOOL handler_readx(int instance) +static bool handler_readx(int instance) { union smb_read parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1352,7 +1354,7 @@ static BOOL handler_readx(int instance) parm[0].readx.in.maxcnt = gen_io_count(); parm[0].readx.in.remaining = gen_io_count(); parm[0].readx.in.read_for_execute = gen_bool(); - parm[0].readx.out.data = talloc_size(current_op.mem_ctx, + parm[0].readx.out.data = talloc_array(current_op.mem_ctx, uint8_t, MAX(parm[0].readx.in.mincnt, parm[0].readx.in.maxcnt)); GEN_COPY_PARM; @@ -1363,13 +1365,13 @@ static BOOL handler_readx(int instance) CHECK_EQUAL(readx.out.compaction_mode); CHECK_EQUAL(readx.out.nread); - return True; + return true; } /* generate writex operations */ -static BOOL handler_writex(int instance) +static bool handler_writex(int instance) { union smb_write parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1380,7 +1382,7 @@ static BOOL handler_writex(int instance) parm[0].writex.in.wmode = gen_bits_mask(0xFFFF); parm[0].writex.in.remaining = gen_io_count(); parm[0].writex.in.count = gen_io_count(); - parm[0].writex.in.data = talloc_zero_size(current_op.mem_ctx, parm[0].writex.in.count); + parm[0].writex.in.data = talloc_zero_array(current_op.mem_ctx, uint8_t, parm[0].writex.in.count); GEN_COPY_PARM; GEN_SET_FNUM(writex.in.file.fnum); @@ -1389,13 +1391,13 @@ static BOOL handler_writex(int instance) CHECK_EQUAL(writex.out.nwritten); CHECK_EQUAL(writex.out.remaining); - return True; + return true; } /* generate lockingx operations */ -static BOOL handler_lockingx(int instance) +static bool handler_lockingx(int instance) { union smb_lock parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1428,7 +1430,7 @@ static BOOL handler_lockingx(int instance) GEN_SET_FNUM(lockx.in.file.fnum); GEN_CALL(smb_raw_lock(tree, &parm[i])); - return True; + return true; } /* @@ -1463,7 +1465,7 @@ static void gen_fileinfo(int instance, union smb_fileinfo *info) /* compare returned fileinfo structures */ -static BOOL cmp_fileinfo(int instance, +static bool cmp_fileinfo(int instance, union smb_fileinfo parm[NSERVERS], NTSTATUS status[NSERVERS]) { @@ -1471,7 +1473,7 @@ static BOOL cmp_fileinfo(int instance, switch (parm[0].generic.level) { case RAW_FILEINFO_GENERIC: - return False; + return false; case RAW_FILEINFO_GETATTR: CHECK_EQUAL(getattr.out.attrib); @@ -1633,13 +1635,13 @@ static BOOL cmp_fileinfo(int instance, break; } - return True; + return true; } /* generate qpathinfo operations */ -static BOOL handler_qpathinfo(int instance) +static bool handler_qpathinfo(int instance) { union smb_fileinfo parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1657,7 +1659,7 @@ static BOOL handler_qpathinfo(int instance) /* generate qfileinfo operations */ -static BOOL handler_qfileinfo(int instance) +static bool handler_qfileinfo(int instance) { union smb_fileinfo parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1775,7 +1777,7 @@ static void gen_setfileinfo(int instance, union smb_setfileinfo *info) /* generate setpathinfo operations */ -static BOOL handler_spathinfo(int instance) +static bool handler_spathinfo(int instance) { union smb_setfileinfo parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1794,14 +1796,14 @@ static BOOL handler_spathinfo(int instance) GEN_CALL(smb_raw_setpathinfo(tree, &parm[i])); - return True; + return true; } /* generate setfileinfo operations */ -static BOOL handler_sfileinfo(int instance) +static bool handler_sfileinfo(int instance) { union smb_setfileinfo parm[NSERVERS]; NTSTATUS status[NSERVERS]; @@ -1814,14 +1816,14 @@ static BOOL handler_sfileinfo(int instance) GEN_SET_FNUM(generic.in.file.fnum); GEN_CALL(smb_raw_setfileinfo(tree, &parm[i])); - return True; + return true; } /* generate change notify operations */ -static BOOL handler_notify(int instance) +static bool handler_notify(int instance) { union smb_notify parm[NSERVERS]; int n; @@ -1842,7 +1844,7 @@ static BOOL handler_notify(int instance) req->async.fn = async_notify; } - return True; + return true; } /* @@ -1896,7 +1898,7 @@ static void dump_seeds(void) */ static struct { const char *name; - BOOL (*handler)(int instance); + bool (*handler)(int instance); int count, success_count; } gen_ops[] = { {"OPEN", handler_open}, @@ -1950,7 +1952,7 @@ static int run_test(void) for (op=0; op<options.numops; op++) { int instance, which_op; - BOOL ret; + bool ret; if (op_parms[op].disabled) continue; @@ -2023,14 +2025,14 @@ static void backtrack_analyze(void) /* mark this range as disabled */ max = MIN(options.numops, base+chunk); for (i=base;i<max; i++) { - op_parms[i].disabled = True; + op_parms[i].disabled = true; } printf("Testing %d ops with %d-%d disabled\n", options.numops, base, max-1); ret = run_test(); printf("Completed %d of %d ops\n", ret, options.numops); for (i=base;i<max; i++) { - op_parms[i].disabled = False; + op_parms[i].disabled = false; } if (ret == options.numops) { /* this chunk is needed */ @@ -2068,7 +2070,7 @@ static void backtrack_analyze(void) /* start the main gentest process */ -static BOOL start_gentest(void) +static bool start_gentest(void) { int op; int ret; @@ -2143,21 +2145,21 @@ static void usage(void) /** split a UNC name into server and share names */ -static BOOL split_unc_name(const char *unc, char **server, char **share) +static bool split_unc_name(const char *unc, char **server, char **share) { char *p = strdup(unc); - if (!p) return False; + if (!p) return false; all_string_sub(p, "\\", "/", 0); - if (strncmp(p, "//", 2) != 0) return False; + if (strncmp(p, "//", 2) != 0) return false; (*server) = p+2; p = strchr(*server, '/'); - if (!p) return False; + if (!p) return false; *p = 0; (*share) = p+1; - return True; + return true; } @@ -2169,7 +2171,7 @@ static BOOL split_unc_name(const char *unc, char **server, char **share) { int opt; int i, username_count=0; - BOOL ret; + bool ret; setlinebuf(stdout); @@ -2194,7 +2196,7 @@ static BOOL split_unc_name(const char *unc, char **server, char **share) argc -= NSERVERS; argv += NSERVERS; - lp_load(); + lp_load(dyn_CONFIGFILE); servers[0].credentials = cli_credentials_init(talloc_autofree_context()); servers[1].credentials = cli_credentials_init(talloc_autofree_context()); @@ -2228,28 +2230,28 @@ static BOOL split_unc_name(const char *unc, char **server, char **share) options.seeds_file = optarg; break; case 'L': - options.use_preset_seeds = True; + options.use_preset_seeds = true; break; case 'F': - options.fast_reconnect = True; + options.fast_reconnect = true; break; case 'o': options.numops = atoi(optarg); break; case 'O': - options.use_oplocks = True; + options.use_oplocks = true; break; case 'a': - options.showall = True; + options.showall = true; break; case 'A': - options.analyze = True; + options.analyze = true; break; case 'X': - options.analyze_always = True; + options.analyze_always = true; break; case 'C': - options.analyze_continuous = True; + options.analyze_continuous = true; break; case 'i': options.ignore_patterns = file_lines_load(optarg, NULL, NULL); diff --git a/source4/torture/ldap/basic.c b/source4/torture/ldap/basic.c index e7d1365c24..3f030c97ba 100644 --- a/source4/torture/ldap/basic.c +++ b/source4/torture/ldap/basic.c @@ -27,37 +27,37 @@ #include "torture/torture.h" #include "torture/ldap/proto.h" -static BOOL test_bind_simple(struct ldap_connection *conn, const char *userdn, const char *password) +static bool test_bind_simple(struct ldap_connection *conn, const char *userdn, const char *password) { NTSTATUS status; - BOOL ret = True; + bool ret = true; status = torture_ldap_bind(conn, userdn, password); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; } return ret; } -static BOOL test_bind_sasl(struct ldap_connection *conn, struct cli_credentials *creds) +static bool test_bind_sasl(struct ldap_connection *conn, struct cli_credentials *creds) { NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("Testing sasl bind as user\n"); status = torture_ldap_bind_sasl(conn, creds); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; } return ret; } -static BOOL test_multibind(struct ldap_connection *conn, const char *userdn, const char *password) +static bool test_multibind(struct ldap_connection *conn, const char *userdn, const char *password) { - BOOL ret = True; + bool ret = true; printf("Testing multiple binds on a single connnection as anonymous and user\n"); @@ -75,9 +75,9 @@ static BOOL test_multibind(struct ldap_connection *conn, const char *userdn, con return ret; } -static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn) +static bool test_search_rootDSE(struct ldap_connection *conn, char **basedn) { - BOOL ret = True; + bool ret = true; struct ldap_message *msg, *result; struct ldap_request *req; int i; @@ -90,7 +90,7 @@ static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn) msg = new_ldap_message(conn); if (!msg) { - return False; + return false; } msg->type = LDAP_TAG_SearchRequest; @@ -99,7 +99,7 @@ static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn) msg->r.SearchRequest.deref = LDAP_DEREFERENCE_NEVER; msg->r.SearchRequest.timelimit = 0; msg->r.SearchRequest.sizelimit = 0; - msg->r.SearchRequest.attributesonly = False; + msg->r.SearchRequest.attributesonly = false; msg->r.SearchRequest.tree = ldb_parse_tree(msg, "(objectclass=*)"); msg->r.SearchRequest.num_attributes = 0; msg->r.SearchRequest.attributes = NULL; @@ -107,13 +107,13 @@ static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn) req = ldap_request_send(conn, msg); if (req == NULL) { printf("Could not setup ldap search\n"); - return False; + return false; } status = ldap_result_one(req, &result, LDAP_TAG_SearchResultEntry); if (!NT_STATUS_IS_OK(status)) { printf("search failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("received %d replies\n", req->num_replies); @@ -142,7 +142,7 @@ static BOOL test_search_rootDSE(struct ldap_connection *conn, char **basedn) return ret; } -static BOOL test_compare_sasl(struct ldap_connection *conn, const char *basedn) +static bool test_compare_sasl(struct ldap_connection *conn, const char *basedn) { struct ldap_message *msg, *rep; struct ldap_request *req; @@ -152,12 +152,12 @@ static BOOL test_compare_sasl(struct ldap_connection *conn, const char *basedn) printf("Testing SASL Compare: %s\n", basedn); if (!basedn) { - return False; + return false; } msg = new_ldap_message(conn); if (!msg) { - return False; + return false; } msg->type = LDAP_TAG_CompareRequest; @@ -168,13 +168,13 @@ static BOOL test_compare_sasl(struct ldap_connection *conn, const char *basedn) req = ldap_request_send(conn, msg); if (!req) { - return False; + return false; } status = ldap_result_one(req, &rep, LDAP_TAG_CompareResponse); if (!NT_STATUS_IS_OK(status)) { printf("error in ldap compare request - %s\n", nt_errstr(status)); - return False; + return false; } DEBUG(5,("Code: %d DN: [%s] ERROR:[%s] REFERRAL:[%s]\n", @@ -183,16 +183,16 @@ static BOOL test_compare_sasl(struct ldap_connection *conn, const char *basedn) rep->r.CompareResponse.errormessage, rep->r.CompareResponse.referral)); - return True; + return true; } -BOOL torture_ldap_basic(struct torture_context *torture) +bool torture_ldap_basic(struct torture_context *torture) { NTSTATUS status; struct ldap_connection *conn; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; const char *host = torture_setting_string(torture, "host", NULL); const char *userdn = torture_setting_string(torture, "ldap_userdn", NULL); const char *secret = torture_setting_string(torture, "ldap_secret", NULL); @@ -205,25 +205,25 @@ BOOL torture_ldap_basic(struct torture_context *torture) status = torture_ldap_connection(mem_ctx, &conn, url); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } if (!test_search_rootDSE(conn, &basedn)) { - ret = False; + ret = false; } /* other basic tests here */ if (!test_multibind(conn, userdn, secret)) { - ret = False; + ret = false; } if (!test_bind_sasl(conn, cmdline_credentials)) { - ret = False; + ret = false; } if (!test_compare_sasl(conn, basedn)) { - ret = False; + ret = false; } /* no more test we are closing */ diff --git a/source4/torture/ldap/cldap.c b/source4/torture/ldap/cldap.c index 8b7fa20b74..f258a1c32f 100644 --- a/source4/torture/ldap/cldap.c +++ b/source4/torture/ldap/cldap.c @@ -31,7 +31,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ } \ } while (0) @@ -39,7 +39,7 @@ /* test netlogon operations */ -static BOOL test_cldap_netlogon(TALLOC_CTX *mem_ctx, const char *dest) +static bool test_cldap_netlogon(TALLOC_CTX *mem_ctx, const char *dest) { struct cldap_socket *cldap = cldap_socket_init(mem_ctx, NULL); NTSTATUS status; @@ -47,7 +47,7 @@ static BOOL test_cldap_netlogon(TALLOC_CTX *mem_ctx, const char *dest) union nbt_cldap_netlogon n1; struct GUID guid; int i; - BOOL ret = True; + bool ret = true; ZERO_STRUCT(search); search.in.dest_address = dest; @@ -203,12 +203,12 @@ static void cldap_dump_results(struct cldap_search *search) /* test generic cldap operations */ -static BOOL test_cldap_generic(TALLOC_CTX *mem_ctx, const char *dest) +static bool test_cldap_generic(TALLOC_CTX *mem_ctx, const char *dest) { struct cldap_socket *cldap = cldap_socket_init(mem_ctx, NULL); NTSTATUS status; struct cldap_search search; - BOOL ret = True; + bool ret = true; const char *attrs1[] = { "currentTime", "highestCommittedUSN", NULL }; const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL }; const char *attrs3[] = { "netlogon", NULL }; @@ -270,10 +270,10 @@ done: return ret; } -BOOL torture_cldap(struct torture_context *torture) +bool torture_cldap(struct torture_context *torture) { TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; const char *host = torture_setting_string(torture, "host", NULL); mem_ctx = talloc_init("torture_cldap"); diff --git a/source4/torture/ldap/cldapbench.c b/source4/torture/ldap/cldapbench.c index 52d8689927..9f860f98d9 100644 --- a/source4/torture/ldap/cldapbench.c +++ b/source4/torture/ldap/cldapbench.c @@ -53,7 +53,7 @@ static bool bench_cldap(struct torture_context *tctx, const char *address) struct cldap_socket *cldap = cldap_socket_init(tctx, NULL); int num_sent=0; struct timeval tv = timeval_current(); - BOOL ret = True; + bool ret = true; int timelimit = torture_setting_int(tctx, "timelimit", 10); struct cldap_netlogon search; struct bench_state *state; diff --git a/source4/torture/ldap/schema.c b/source4/torture/ldap/schema.c index f754880d0b..30fd9877e6 100644 --- a/source4/torture/ldap/schema.c +++ b/source4/torture/ldap/schema.c @@ -31,6 +31,8 @@ #include "torture/torture.h" #include "torture/ldap/proto.h" +#include "param/param.h" + struct test_rootDSE { const char *defaultdn; const char *rootdn; @@ -41,13 +43,13 @@ struct test_rootDSE { struct test_schema_ctx { struct ldb_paged_control *ctrl; uint32_t count; - BOOL pending; + bool pending; int (*callback)(void *, struct ldb_context *ldb, struct ldb_message *); void *private_data; }; -static BOOL test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *root) +static bool test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *root) { int ret; struct ldb_message *msg; @@ -58,10 +60,10 @@ static BOOL test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *ro ret = ldb_search(ldb, ldb_dn_new(ldb, ldb, NULL), LDB_SCOPE_BASE, NULL, NULL, &r); if (ret != LDB_SUCCESS) { - return False; + return false; } else if (r->count != 1) { talloc_free(r); - return False; + return false; } msg = r->msgs[0]; @@ -77,7 +79,7 @@ static BOOL test_search_rootDSE(struct ldb_context *ldb, struct test_rootDSE *ro talloc_free(r); - return True; + return true; } static int test_schema_search_callback(struct ldb_context *ldb, void *context, struct ldb_reply *ares) @@ -113,7 +115,7 @@ static int test_schema_search_callback(struct ldb_context *ldb, void *context, s actx->ctrl->cookie_len = ctrl->cookie_len; if (actx->ctrl->cookie_len > 0) { - actx->pending = True; + actx->pending = true; } } break; @@ -136,7 +138,7 @@ static int test_schema_search_callback(struct ldb_context *ldb, void *context, s return LDB_SUCCESS; } -static BOOL test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE *root, +static bool test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE *root, const char *filter, int (*callback)(void *, struct ldb_context *ldb, struct ldb_message *), void *private_data) @@ -153,7 +155,7 @@ static BOOL test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE ctrl = talloc_array(req, struct ldb_control *, 2); ctrl[0] = talloc(ctrl, struct ldb_control); ctrl[0]->oid = LDB_CONTROL_PAGED_RESULTS_OID; - ctrl[0]->critical = True; + ctrl[0]->critical = true; control = talloc(ctrl[0], struct ldb_paged_control); control->size = 1000; control->cookie = NULL; @@ -177,25 +179,25 @@ static BOOL test_create_schema_type(struct ldb_context *ldb, struct test_rootDSE actx->callback = callback; actx->private_data = private_data; again: - actx->pending = False; + actx->pending = false; ret = ldb_request(ldb, req); if (ret != LDB_SUCCESS) { d_printf("search failed - %s\n", ldb_errstring(ldb)); - return False; + return false; } ret = ldb_wait(req->handle, LDB_WAIT_ALL); if (ret != LDB_SUCCESS) { d_printf("search error - %s\n", ldb_errstring(ldb)); - return False; + return false; } if (actx->pending) goto again; d_printf("filter[%s] count[%u]\n", filter, actx->count); - return True; + return true; } static int test_add_attribute(void *ptr, struct ldb_context *ldb, struct ldb_message *msg) @@ -243,9 +245,9 @@ failed: return LDB_ERR_OTHER; } -static BOOL test_create_schema(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema **_schema) +static bool test_create_schema(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema **_schema) { - BOOL ret = True; + bool ret = true; struct dsdb_schema *schema; schema = talloc_zero(ldb, struct dsdb_schema); @@ -257,13 +259,13 @@ static BOOL test_create_schema(struct ldb_context *ldb, struct test_rootDSE *roo ret &= test_create_schema_type(ldb, root, "(objectClass=classSchema)", test_add_class, schema); - if (ret == True) { + if (ret == true) { *_schema = schema; } return ret; } -static BOOL test_dump_not_replicated(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema) +static bool test_dump_not_replicated(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema) { struct dsdb_attribute *a; uint32_t a_i = 1; @@ -276,10 +278,10 @@ static BOOL test_dump_not_replicated(struct ldb_context *ldb, struct test_rootDS a->lDAPDisplayName); } - return True; + return true; } -static BOOL test_dump_partial(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema) +static bool test_dump_partial(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema) { struct dsdb_attribute *a; uint32_t a_i = 1; @@ -293,10 +295,10 @@ static BOOL test_dump_partial(struct ldb_context *ldb, struct test_rootDSE *root a->lDAPDisplayName); } - return True; + return true; } -static BOOL test_dump_contructed(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema) +static bool test_dump_contructed(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema) { struct dsdb_attribute *a; uint32_t a_i = 1; @@ -309,10 +311,10 @@ static BOOL test_dump_contructed(struct ldb_context *ldb, struct test_rootDSE *r a->lDAPDisplayName); } - return True; + return true; } -static BOOL test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema) +static bool test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE *root, struct dsdb_schema *schema) { struct dsdb_attribute *a; uint32_t a_i = 1; @@ -348,7 +350,7 @@ static BOOL test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE om_hex = data_blob_hex_string(ldb, &a->oMObjectClass); if (!om_hex) { - return False; + return false; } d_printf("attr[%4u]: %s %u '%s' '%s'\n", a_i++, @@ -358,13 +360,13 @@ static BOOL test_dump_sorted_syntax(struct ldb_context *ldb, struct test_rootDSE } } - return True; + return true; } -BOOL torture_ldap_schema(struct torture_context *torture) +bool torture_ldap_schema(struct torture_context *torture) { struct ldb_context *ldb; - BOOL ret = True; + bool ret = true; const char *host = torture_setting_string(torture, "host", NULL); char *url; struct test_rootDSE rootDSE; @@ -374,7 +376,7 @@ BOOL torture_ldap_schema(struct torture_context *torture) url = talloc_asprintf(torture, "ldap://%s/", host); - ldb = ldb_wrap_connect(torture, url, + ldb = ldb_wrap_connect(torture, global_loadparm, url, NULL, cmdline_credentials, 0, NULL); diff --git a/source4/torture/ldap/uptodatevector.c b/source4/torture/ldap/uptodatevector.c index 0ff9948cad..b3c6e8d555 100644 --- a/source4/torture/ldap/uptodatevector.c +++ b/source4/torture/ldap/uptodatevector.c @@ -34,6 +34,8 @@ #include "librpc/ndr/libndr.h" #include "librpc/gen_ndr/ndr_drsblobs.h" +#include "param/param.h" + static bool test_check_uptodatevector(struct torture_context *torture, struct ldb_context *ldb, struct ldb_dn *partition_dn) @@ -148,17 +150,17 @@ static bool test_check_uptodatevector(struct torture_context *torture, return ok; } -BOOL torture_ldap_uptodatevector(struct torture_context *torture) +bool torture_ldap_uptodatevector(struct torture_context *torture) { struct ldb_context *ldb; - BOOL ret = True; + bool ret = true; const char *host = torture_setting_string(torture, "host", NULL); char *url; url = talloc_asprintf(torture, "ldap://%s/", host); if (!url) goto failed; - ldb = ldb_wrap_connect(torture, url, + ldb = ldb_wrap_connect(torture, global_loadparm, url, NULL, cmdline_credentials, 0, NULL); @@ -170,5 +172,5 @@ BOOL torture_ldap_uptodatevector(struct torture_context *torture) return ret; failed: - return False; + return false; } diff --git a/source4/torture/libnet/domain.c b/source4/torture/libnet/domain.c index 17b8a94f42..daf9012e0c 100644 --- a/source4/torture/libnet/domain.c +++ b/source4/torture/libnet/domain.c @@ -23,8 +23,9 @@ #include "lib/events/events.h" #include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "param/param.h" -static BOOL test_domainopen(struct libnet_context *net_ctx, TALLOC_CTX *mem_ctx, +static bool test_domainopen(struct libnet_context *net_ctx, TALLOC_CTX *mem_ctx, struct lsa_String *domname, struct policy_handle *domain_handle) { @@ -39,15 +40,15 @@ static BOOL test_domainopen(struct libnet_context *net_ctx, TALLOC_CTX *mem_ctx, status = libnet_DomainOpen(net_ctx, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { printf("Composite domain open failed - %s\n", nt_errstr(status)); - return False; + return false; } *domain_handle = io.out.domain_handle; - return True; + return true; } -static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { NTSTATUS status; @@ -62,20 +63,20 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Close(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Close failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -BOOL torture_domainopen(struct torture_context *torture) +bool torture_domainopen(struct torture_context *torture) { NTSTATUS status; struct libnet_context *net_ctx; struct event_context *evt_ctx; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct policy_handle h; struct lsa_String name; @@ -89,21 +90,21 @@ BOOL torture_domainopen(struct torture_context *torture) &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } - name.string = lp_workgroup(); + name.string = lp_workgroup(global_loadparm); /* * Testing synchronous version */ if (!test_domainopen(net_ctx, mem_ctx, &name, &h)) { - ret = False; + ret = false; goto done; } if (!test_cleanup(net_ctx->samr.pipe, mem_ctx, &h)) { - ret = False; + ret = false; goto done; } diff --git a/source4/torture/libnet/groupinfo.c b/source4/torture/libnet/groupinfo.c index 0dca1519de..bff2f405cd 100644 --- a/source4/torture/libnet/groupinfo.c +++ b/source4/torture/libnet/groupinfo.c @@ -23,163 +23,13 @@ #include "libnet/libnet.h" #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "param/param.h" +#include "torture/libnet/utils.h" #define TEST_GROUPNAME "libnetgroupinfotest" -static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, struct lsa_String *domname, - struct dom_sid2 *sid) -{ - NTSTATUS status; - struct policy_handle h, domain_handle; - struct samr_Connect r1; - struct samr_LookupDomain r2; - struct samr_OpenDomain r3; - - printf("connecting\n"); - - r1.in.system_name = 0; - r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r1.out.connect_handle = &h; - - status = dcerpc_samr_Connect(p, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - printf("Connect failed - %s\n", nt_errstr(status)); - return False; - } - - r2.in.connect_handle = &h; - r2.in.domain_name = domname; - - printf("domain lookup on %s\n", domname->string); - - status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - printf("LookupDomain failed - %s\n", nt_errstr(status)); - return False; - } - - r3.in.connect_handle = &h; - r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r3.in.sid = r2.out.sid; - r3.out.domain_handle = &domain_handle; - - printf("opening domain\n"); - - status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenDomain failed - %s\n", nt_errstr(status)); - return False; - } else { - *handle = domain_handle; - } - - *sid = *r2.out.sid; - return True; -} - - -static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *domain_handle, const char *groupname) -{ - NTSTATUS status; - struct samr_LookupNames r1; - struct samr_OpenGroup r2; - struct samr_DeleteDomainGroup r3; - struct lsa_String names[2]; - uint32_t rid; - struct policy_handle group_handle; - - names[0].string = groupname; - - r1.in.domain_handle = domain_handle; - r1.in.num_names = 1; - r1.in.names = names; - - printf("group account lookup '%s'\n", groupname); - - status = dcerpc_samr_LookupNames(p, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - printf("LookupNames failed - %s\n", nt_errstr(status)); - return False; - } - - rid = r1.out.rids.ids[0]; - - r2.in.domain_handle = domain_handle; - r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r2.in.rid = rid; - r2.out.group_handle = &group_handle; - - printf("opening group account\n"); - - status = dcerpc_samr_OpenGroup(p, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenUser failed - %s\n", nt_errstr(status)); - return False; - } - - r3.in.group_handle = &group_handle; - r3.out.group_handle = &group_handle; - - printf("deleting group account\n"); - - status = dcerpc_samr_DeleteDomainGroup(p, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - printf("DeleteGroup failed - %s\n", nt_errstr(status)); - return False; - } - - return True; -} - - -static BOOL test_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, const char *name, uint32_t *rid) -{ - NTSTATUS status; - struct lsa_String groupname; - struct samr_CreateDomainGroup r; - struct policy_handle group_handle; - - groupname.string = name; - - r.in.domain_handle = handle; - r.in.name = &groupname; - r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r.out.group_handle = &group_handle; - r.out.rid = rid; - - printf("creating group account %s\n", name); - - status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("CreateGroup failed - %s\n", nt_errstr(status)); - - if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { - printf("Group (%s) already exists - attempting to delete and recreate account again\n", name); - if (!test_cleanup(p, mem_ctx, handle, TEST_GROUPNAME)) { - return False; - } - - printf("creating group account\n"); - - status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("CreateGroup failed - %s\n", nt_errstr(status)); - return False; - } - return True; - } - return False; - } - - return True; -} - - -static BOOL test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, struct dom_sid2 *domain_sid, const char* group_name, uint32_t *rid) @@ -199,7 +49,7 @@ static BOOL test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = libnet_rpc_groupinfo(p, mem_ctx, &group); if (!NT_STATUS_IS_OK(status)) { printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status)); - return False; + return false; } ZERO_STRUCT(group); @@ -213,19 +63,19 @@ static BOOL test_groupinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = libnet_rpc_groupinfo(p, mem_ctx, &group); if (!NT_STATUS_IS_OK(status)) { printf("Failed to call sync libnet_rpc_groupinfo - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -BOOL torture_groupinfo(struct torture_context *torture) +bool torture_groupinfo(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct policy_handle h; struct lsa_String name; struct dom_sid2 sid; @@ -238,31 +88,31 @@ BOOL torture_groupinfo(struct torture_context *torture) &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } - name.string = lp_workgroup(); + name.string = lp_workgroup(global_loadparm); /* * Testing synchronous version */ if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) { - ret = False; + ret = false; goto done; } - if (!test_create(p, mem_ctx, &h, TEST_GROUPNAME, &rid)) { - ret = False; + if (!test_group_create(p, mem_ctx, &h, TEST_GROUPNAME, &rid)) { + ret = false; goto done; } if (!test_groupinfo(p, mem_ctx, &h, &sid, TEST_GROUPNAME, &rid)) { - ret = False; + ret = false; goto done; } - if (!test_cleanup(p, mem_ctx, &h, TEST_GROUPNAME)) { - ret = False; + if (!test_group_cleanup(p, mem_ctx, &h, TEST_GROUPNAME)) { + ret = false; goto done; } diff --git a/source4/torture/libnet/groupman.c b/source4/torture/libnet/groupman.c new file mode 100644 index 0000000000..552e02c420 --- /dev/null +++ b/source4/torture/libnet/groupman.c @@ -0,0 +1,93 @@ +/* + Unix SMB/CIFS implementation. + Test suite for libnet calls. + + Copyright (C) Rafal Szczesniak 2007 + + 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 "torture/rpc/rpc.h" +#include "torture/libnet/grouptest.h" +#include "libnet/libnet.h" +#include "librpc/gen_ndr/ndr_samr_c.h" +#include "param/param.h" +#include "torture/libnet/utils.h" + + +static bool test_groupadd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *domain_handle, + const char *name) +{ + NTSTATUS status; + bool ret = true; + struct libnet_rpc_groupadd group; + + group.in.domain_handle = *domain_handle; + group.in.groupname = name; + + printf("Testing libnet_rpc_groupadd\n"); + + status = libnet_rpc_groupadd(p, mem_ctx, &group); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to call sync libnet_rpc_groupadd - %s\n", nt_errstr(status)); + return false; + } + + return ret; +} + + +bool torture_groupadd(struct torture_context *torture) +{ + NTSTATUS status; + struct dcerpc_pipe *p; + struct policy_handle h; + struct lsa_String domain_name; + struct dom_sid2 sid; + const char *name = TEST_GROUPNAME; + TALLOC_CTX *mem_ctx; + bool ret = true; + + mem_ctx = talloc_init("test_groupadd"); + + status = torture_rpc_connection(torture, + &p, + &ndr_table_samr); + + if (!NT_STATUS_IS_OK(status)) { + return false; + } + + domain_name.string = lp_workgroup(global_loadparm); + if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) { + ret = false; + goto done; + } + + if (!test_groupadd(p, mem_ctx, &h, name)) { + ret = false; + goto done; + } + + if (!test_group_cleanup(p, mem_ctx, &h, name)) { + ret = false; + goto done; + } + +done: + talloc_free(mem_ctx); + return ret; +} diff --git a/source4/torture/libnet/grouptest.h b/source4/torture/libnet/grouptest.h new file mode 100644 index 0000000000..9d030acd17 --- /dev/null +++ b/source4/torture/libnet/grouptest.h @@ -0,0 +1,20 @@ +/* + Unix SMB/CIFS implementation. + + Copyright (C) Rafal Szczesniak 2007 + + 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/>. +*/ + +#define TEST_GROUPNAME "libnetgrptest" diff --git a/source4/torture/libnet/libnet.c b/source4/torture/libnet/libnet.c index dc0e35e102..0e5c9301f8 100644 --- a/source4/torture/libnet/libnet.c +++ b/source4/torture/libnet/libnet.c @@ -31,6 +31,7 @@ NTSTATUS torture_net_init(void) torture_suite_add_simple_test(suite, "USERMOD", torture_usermod); torture_suite_add_simple_test(suite, "DOMOPEN", torture_domainopen); torture_suite_add_simple_test(suite, "GROUPINFO", torture_groupinfo); + torture_suite_add_simple_test(suite, "GROUPADD", torture_groupadd); torture_suite_add_simple_test(suite, "API-LOOKUP", torture_lookup); torture_suite_add_simple_test(suite, "API-LOOKUPHOST", torture_lookup_host); torture_suite_add_simple_test(suite, "API-LOOKUPPDC", torture_lookup_pdc); diff --git a/source4/torture/libnet/libnet_BecomeDC.c b/source4/torture/libnet/libnet_BecomeDC.c index 9d67e093b1..edcf92b8ec 100644 --- a/source4/torture/libnet/libnet_BecomeDC.c +++ b/source4/torture/libnet/libnet_BecomeDC.c @@ -163,7 +163,7 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data, DEBUG(0,("Pathes under PRIVATEDIR[%s]\n" "SAMDB[%s] SECRETS[%s] KEYTAB[%s]\n", - lp_private_dir(), + lp_private_dir(global_loadparm), s->path.samdb_ldb, s->path.secrets_ldb, s->path.secrets_keytab)); @@ -256,7 +256,7 @@ static NTSTATUS test_become_dc_prepare_db(void *private_data, DEBUG(0,("Open the SAM LDB with system credentials: %s\n", s->path.samdb_ldb)); - s->ldb = ldb_wrap_connect(s, s->path.samdb_ldb, + s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb, system_session(s), NULL, 0, NULL); if (!s->ldb) { @@ -345,7 +345,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s, tmp_dns_name = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid); NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name); - tmp_dns_name = talloc_asprintf_append(tmp_dns_name, "._msdcs.%s", c->forest->dns_name); + tmp_dns_name = talloc_asprintf_append_buffer(tmp_dns_name, "._msdcs.%s", c->forest->dns_name); NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name); s_dsa->other_info->dns_name = tmp_dns_name; @@ -442,7 +442,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s, return werror_to_ntstatus(status); } - if (lp_parm_bool(-1, "become dc", "dump objects", False)) { + if (lp_parm_bool(global_loadparm, NULL, "become dc", "dump objects", false)) { for (i=0; i < objs->num_objects; i++) { struct ldb_ldif ldif; fprintf(stdout, "#\n"); @@ -484,7 +484,7 @@ static NTSTATUS test_apply_schema(struct test_become_dc_state *s, s->schema = NULL; DEBUG(0,("Reopen the SAM LDB with system credentials and a already stored schema: %s\n", s->path.samdb_ldb)); - s->ldb = ldb_wrap_connect(s, s->path.samdb_ldb, + s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb, system_session(s), NULL, 0, NULL); if (!s->ldb) { @@ -642,7 +642,7 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data, tmp_dns_name = GUID_string(s_dsa->other_info, &s_dsa->source_dsa_obj_guid); NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name); - tmp_dns_name = talloc_asprintf_append(tmp_dns_name, "._msdcs.%s", c->forest->dns_name); + tmp_dns_name = talloc_asprintf_append_buffer(tmp_dns_name, "._msdcs.%s", c->forest->dns_name); NT_STATUS_HAVE_NO_MEMORY(tmp_dns_name); s_dsa->other_info->dns_name = tmp_dns_name; @@ -670,7 +670,7 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data, return werror_to_ntstatus(status); } - if (lp_parm_bool(-1, "become dc", "dump objects", False)) { + if (lp_parm_bool(global_loadparm, NULL, "become dc", "dump objects", false)) { for (i=0; i < objs->num_objects; i++) { struct ldb_ldif ldif; fprintf(stdout, "#\n"); @@ -700,7 +700,7 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data, return NT_STATUS_FOOBAR; } - if (lp_parm_bool(-1, "become dc", "dump objects", False)) { + if (lp_parm_bool(global_loadparm, NULL, "become dc", "dump objects", false)) { DEBUG(0,("# %s\n", sa->lDAPDisplayName)); NDR_PRINT_DEBUG(drsuapi_DsReplicaLinkedAttribute, &linked_attributes[i]); dump_data(0, @@ -712,9 +712,9 @@ static NTSTATUS test_become_dc_store_chunk(void *private_data, return NT_STATUS_OK; } -BOOL torture_net_become_dc(struct torture_context *torture) +bool torture_net_become_dc(struct torture_context *torture) { - BOOL ret = True; + bool ret = true; NTSTATUS status; struct libnet_BecomeDC b; struct libnet_UnbecomeDC u; @@ -724,9 +724,9 @@ BOOL torture_net_become_dc(struct torture_context *torture) uint32_t i; s = talloc_zero(torture, struct test_become_dc_state); - if (!s) return False; + if (!s) return false; - s->netbios_name = lp_parm_string(-1, "become dc", "smbtorture dc"); + s->netbios_name = lp_parm_string(global_loadparm, NULL, "become dc", "smbtorture dc"); if (!s->netbios_name || !s->netbios_name[0]) { s->netbios_name = "smbtorturedc"; } @@ -751,7 +751,7 @@ BOOL torture_net_become_dc(struct torture_context *torture) if (!s->tj) { DEBUG(0, ("%s failed to join domain as workstation\n", s->netbios_name)); - return False; + return false; } s->ctx = libnet_context_init(torture->ev); @@ -776,27 +776,27 @@ BOOL torture_net_become_dc(struct torture_context *torture) status = libnet_BecomeDC(s->ctx, s, &b); if (!NT_STATUS_IS_OK(status)) { printf("libnet_BecomeDC() failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; goto cleanup; } msg = ldb_msg_new(s); if (!msg) { printf("ldb_msg_new() failed\n"); - ret = False; + ret = false; goto cleanup; } msg->dn = ldb_dn_new(msg, s->ldb, "cn=ROOTDSE"); if (!msg->dn) { printf("ldb_msg_new(cn=ROOTDSE) failed\n"); - ret = False; + ret = false; goto cleanup; } ldb_ret = ldb_msg_add_string(msg, "isSynchronized", "TRUE"); if (ldb_ret != LDB_SUCCESS) { printf("ldb_msg_add_string(msg, isSynchronized, TRUE) failed: %d\n", ldb_ret); - ret = False; + ret = false; goto cleanup; } @@ -808,7 +808,7 @@ BOOL torture_net_become_dc(struct torture_context *torture) ldb_ret = ldb_modify(s->ldb, msg); if (ldb_ret != LDB_SUCCESS) { printf("ldb_modify() failed: %d\n", ldb_ret); - ret = False; + ret = false; goto cleanup; } @@ -817,24 +817,24 @@ BOOL torture_net_become_dc(struct torture_context *torture) s->schema = NULL; DEBUG(0,("Reopen the SAM LDB with system credentials and all replicated data: %s\n", s->path.samdb_ldb)); - s->ldb = ldb_wrap_connect(s, s->path.samdb_ldb, + s->ldb = ldb_wrap_connect(s, global_loadparm, s->path.samdb_ldb, system_session(s), NULL, 0, NULL); if (!s->ldb) { DEBUG(0,("Failed to open '%s'\n", s->path.samdb_ldb)); - ret = False; + ret = false; goto cleanup; } s->schema = dsdb_get_schema(s->ldb); if (!s->schema) { DEBUG(0,("Failed to get loaded dsdb_schema\n")); - ret = False; + ret = false; goto cleanup; } - if (lp_parm_bool(-1, "become dc", "do not unjoin", false)) { + if (lp_parm_bool(global_loadparm, NULL, "become dc", "do not unjoin", false)) { talloc_free(s); return ret; } @@ -849,7 +849,7 @@ cleanup: status = libnet_UnbecomeDC(s->ctx, s, &u); if (!NT_STATUS_IS_OK(status)) { printf("libnet_UnbecomeDC() failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* Leave domain. */ diff --git a/source4/torture/libnet/libnet_domain.c b/source4/torture/libnet/libnet_domain.c index 675ab9f099..379cca19be 100644 --- a/source4/torture/libnet/libnet_domain.c +++ b/source4/torture/libnet/libnet_domain.c @@ -30,9 +30,10 @@ #include "librpc/rpc/dcerpc.h" #include "torture/torture.h" #include "torture/rpc/rpc.h" +#include "param/param.h" -static BOOL test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *domname, uint32_t *access_mask, struct dom_sid **sid) { @@ -53,7 +54,7 @@ static BOOL test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Connect(p, mem_ctx, &r1); if (!NT_STATUS_IS_OK(status)) { printf("Connect failed - %s\n", nt_errstr(status)); - return False; + return false; } r2.in.connect_handle = &h; @@ -64,7 +65,7 @@ static BOOL test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2); if (!NT_STATUS_IS_OK(status)) { printf("LookupDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } r3.in.connect_handle = &h; @@ -77,16 +78,16 @@ static BOOL test_opendomain_samr(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3); if (!NT_STATUS_IS_OK(status)) { printf("OpenDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } else { *handle = domain_handle; } - return True; + return true; } -static BOOL test_opendomain_lsa(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_opendomain_lsa(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *domname, uint32_t *access_mask) { @@ -114,16 +115,16 @@ static BOOL test_opendomain_lsa(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_lsa_OpenPolicy2(p, mem_ctx, &open); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } - return True; + return true; } bool torture_domain_open_lsa(struct torture_context *torture) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct libnet_context *ctx; struct libnet_DomainOpen r; struct lsa_Close lsa_close; @@ -133,12 +134,12 @@ bool torture_domain_open_lsa(struct torture_context *torture) /* we're accessing domain controller so the domain name should be passed (it's going to be resolved to dc name and address) instead of specific server name. */ - domain_name = lp_workgroup(); + domain_name = lp_workgroup(global_loadparm); ctx = libnet_context_init(NULL); if (ctx == NULL) { d_printf("failed to create libnet context\n"); - return False; + return false; } ctx->cred = cmdline_credentials; @@ -151,7 +152,7 @@ bool torture_domain_open_lsa(struct torture_context *torture) status = libnet_DomainOpen(ctx, torture, &r); if (!NT_STATUS_IS_OK(status)) { d_printf("failed to open domain on lsa service: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } @@ -162,7 +163,7 @@ bool torture_domain_open_lsa(struct torture_context *torture) status = dcerpc_lsa_Close(ctx->lsa.pipe, ctx, &lsa_close); if (!NT_STATUS_IS_OK(status)) { d_printf("failed to close domain on lsa service: %s\n", nt_errstr(status)); - ret = False; + ret = false; } done: @@ -171,9 +172,9 @@ done: } -BOOL torture_domain_close_lsa(struct torture_context *torture) +bool torture_domain_close_lsa(struct torture_context *torture) { - BOOL ret = True; + bool ret = true; NTSTATUS status; TALLOC_CTX *mem_ctx=NULL; struct libnet_context *ctx; @@ -192,7 +193,7 @@ BOOL torture_domain_close_lsa(struct torture_context *torture) ctx = libnet_context_init(NULL); if (ctx == NULL) { d_printf("failed to create libnet context\n"); - ret = False; + ret = false; goto done; } @@ -203,15 +204,15 @@ BOOL torture_domain_close_lsa(struct torture_context *torture) cmdline_credentials, NULL); if (!NT_STATUS_IS_OK(status)) { d_printf("failed to connect to server: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } - domain_name.string = lp_workgroup(); + domain_name.string = lp_workgroup(global_loadparm); if (!test_opendomain_lsa(p, torture, &h, &domain_name, &access_mask)) { d_printf("failed to open domain on lsa service\n"); - ret = False; + ret = false; goto done; } @@ -229,7 +230,7 @@ BOOL torture_domain_close_lsa(struct torture_context *torture) status = libnet_DomainClose(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto done; } @@ -240,7 +241,7 @@ done: } -BOOL torture_domain_open_samr(struct torture_context *torture) +bool torture_domain_open_samr(struct torture_context *torture) { NTSTATUS status; struct libnet_context *ctx; @@ -250,7 +251,7 @@ BOOL torture_domain_open_samr(struct torture_context *torture) struct libnet_DomainOpen io; struct samr_Close r; const char *domain_name; - BOOL ret = True; + bool ret = true; mem_ctx = talloc_init("test_domainopen_lsa"); @@ -260,7 +261,7 @@ BOOL torture_domain_open_samr(struct torture_context *torture) /* we're accessing domain controller so the domain name should be passed (it's going to be resolved to dc name and address) instead of specific server name. */ - domain_name = lp_workgroup(); + domain_name = lp_workgroup(global_loadparm); /* * Testing synchronous version @@ -274,7 +275,7 @@ BOOL torture_domain_open_samr(struct torture_context *torture) status = libnet_DomainOpen(ctx, mem_ctx, &io); if (!NT_STATUS_IS_OK(status)) { printf("Composite domain open failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } @@ -288,7 +289,7 @@ BOOL torture_domain_open_samr(struct torture_context *torture) status = dcerpc_samr_Close(ctx->samr.pipe, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Close failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } @@ -300,9 +301,9 @@ done: } -BOOL torture_domain_close_samr(struct torture_context *torture) +bool torture_domain_close_samr(struct torture_context *torture) { - BOOL ret = True; + bool ret = true; NTSTATUS status; TALLOC_CTX *mem_ctx = NULL; struct libnet_context *ctx; @@ -322,7 +323,7 @@ BOOL torture_domain_close_samr(struct torture_context *torture) ctx = libnet_context_init(NULL); if (ctx == NULL) { d_printf("failed to create libnet context\n"); - ret = False; + ret = false; goto done; } @@ -333,15 +334,15 @@ BOOL torture_domain_close_samr(struct torture_context *torture) ctx->cred, NULL); if (!NT_STATUS_IS_OK(status)) { d_printf("failed to connect to server: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } - domain_name.string = talloc_strdup(mem_ctx, lp_workgroup()); + domain_name.string = talloc_strdup(mem_ctx, lp_workgroup(global_loadparm)); if (!test_opendomain_samr(p, torture, &h, &domain_name, &access_mask, &sid)) { d_printf("failed to open domain on samr service\n"); - ret = False; + ret = false; goto done; } @@ -361,7 +362,7 @@ BOOL torture_domain_close_samr(struct torture_context *torture) status = libnet_DomainClose(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto done; } @@ -372,9 +373,9 @@ done: } -BOOL torture_domain_list(struct torture_context *torture) +bool torture_domain_list(struct torture_context *torture) { - BOOL ret = True; + bool ret = true; NTSTATUS status; TALLOC_CTX *mem_ctx = NULL; struct dcerpc_binding *binding; @@ -390,7 +391,7 @@ BOOL torture_domain_list(struct torture_context *torture) ctx = libnet_context_init(NULL); if (ctx == NULL) { d_printf("failed to create libnet context\n"); - ret = False; + ret = false; goto done; } @@ -407,7 +408,7 @@ BOOL torture_domain_list(struct torture_context *torture) status = libnet_DomainList(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto done; } @@ -428,7 +429,7 @@ BOOL torture_domain_list(struct torture_context *torture) status = libnet_DomainList(ctx, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto done; } diff --git a/source4/torture/libnet/libnet_group.c b/source4/torture/libnet/libnet_group.c index 1f4725d6dd..a4489d376d 100644 --- a/source4/torture/libnet/libnet_group.c +++ b/source4/torture/libnet/libnet_group.c @@ -26,12 +26,13 @@ #include "librpc/gen_ndr/ndr_lsa_c.h" #include "torture/torture.h" #include "torture/rpc/rpc.h" +#include "param/param.h" #define TEST_GROUPNAME "libnetgrouptest" -static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, const char *groupname) { NTSTATUS status; @@ -53,7 +54,7 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupNames(p, mem_ctx, &r1); if (!NT_STATUS_IS_OK(status)) { printf("LookupNames failed - %s\n", nt_errstr(status)); - return False; + return false; } rid = r1.out.rids.ids[0]; @@ -68,7 +69,7 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenGroup(p, mem_ctx, &r2); if (!NT_STATUS_IS_OK(status)) { printf("OpenGroup failed - %s\n", nt_errstr(status)); - return False; + return false; } r3.in.group_handle = &group_handle; @@ -79,14 +80,14 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_DeleteDomainGroup(p, mem_ctx, &r3); if (!NT_STATUS_IS_OK(status)) { printf("DeleteGroup failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_creategroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_creategroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char *name) { NTSTATUS status; @@ -112,7 +113,7 @@ static BOOL test_creategroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (NT_STATUS_EQUAL(status, NT_STATUS_GROUP_EXISTS)) { printf("Group (%s) already exists - attempting to delete and recreate group again\n", name); if (!test_cleanup(p, mem_ctx, handle, TEST_GROUPNAME)) { - return False; + return false; } printf("creating group account\n"); @@ -120,18 +121,18 @@ static BOOL test_creategroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("CreateGroup failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } - return False; + return false; } - return True; + return true; } -static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *domname) { NTSTATUS status; @@ -149,7 +150,7 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Connect(p, mem_ctx, &r1); if (!NT_STATUS_IS_OK(status)) { printf("Connect failed - %s\n", nt_errstr(status)); - return False; + return false; } r2.in.connect_handle = &h; @@ -160,7 +161,7 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2); if (!NT_STATUS_IS_OK(status)) { printf("LookupDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } r3.in.connect_handle = &h; @@ -173,16 +174,16 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3); if (!NT_STATUS_IS_OK(status)) { printf("OpenDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } else { *handle = domain_handle; } - return True; + return true; } -static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { NTSTATUS status; @@ -194,17 +195,17 @@ static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Close(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Close samr domain failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -BOOL torture_groupinfo_api(struct torture_context *torture) +bool torture_groupinfo_api(struct torture_context *torture) { const char *name = TEST_GROUPNAME; - BOOL ret = True; + bool ret = true; NTSTATUS status; TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx; struct libnet_context *ctx; @@ -222,17 +223,17 @@ BOOL torture_groupinfo_api(struct torture_context *torture) &p, &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } - domain_name.string = lp_workgroup(); + domain_name.string = lp_workgroup(global_loadparm); if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) { - ret = False; + ret = false; goto done; } if (!test_creategroup(p, prep_mem_ctx, &h, name)) { - ret = False; + ret = false; goto done; } @@ -246,20 +247,20 @@ BOOL torture_groupinfo_api(struct torture_context *torture) status = libnet_GroupInfo(ctx, mem_ctx, &req); if (!NT_STATUS_IS_OK(status)) { printf("libnet_GroupInfo call failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; talloc_free(mem_ctx); goto done; } if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, TEST_GROUPNAME)) { printf("cleanup failed\n"); - ret = False; + ret = false; goto done; } if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { printf("domain close failed\n"); - ret = False; + ret = false; } talloc_free(ctx); diff --git a/source4/torture/libnet/libnet_lookup.c b/source4/torture/libnet/libnet_lookup.c index b48f7e7bac..4734ec5088 100644 --- a/source4/torture/libnet/libnet_lookup.c +++ b/source4/torture/libnet/libnet_lookup.c @@ -26,11 +26,12 @@ #include "libcli/libcli.h" #include "torture/rpc/rpc.h" #include "torture/torture.h" +#include "param/param.h" -BOOL torture_lookup(struct torture_context *torture) +bool torture_lookup(struct torture_context *torture) { - BOOL ret; + bool ret; NTSTATUS status; TALLOC_CTX *mem_ctx; struct libnet_context *ctx; @@ -58,13 +59,13 @@ BOOL torture_lookup(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { printf("Couldn't lookup name %s: %s\n", lookup.in.hostname, nt_errstr(status)); - ret = False; + ret = false; goto done; } - ret = True; + ret = true; - printf("Name [%s] found at adrress: %s.\n", lookup.in.hostname, *lookup.out.address); + printf("Name [%s] found at address: %s.\n", lookup.in.hostname, *lookup.out.address); done: talloc_free(mem_ctx); @@ -72,9 +73,9 @@ done: } -BOOL torture_lookup_host(struct torture_context *torture) +bool torture_lookup_host(struct torture_context *torture) { - BOOL ret; + bool ret; NTSTATUS status; TALLOC_CTX *mem_ctx; struct libnet_context *ctx; @@ -101,13 +102,13 @@ BOOL torture_lookup_host(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { printf("Couldn't lookup host %s: %s\n", lookup.in.hostname, nt_errstr(status)); - ret = False; + ret = false; goto done; } - ret = True; + ret = true; - printf("Host [%s] found at adrress: %s.\n", lookup.in.hostname, *lookup.out.address); + printf("Host [%s] found at address: %s.\n", lookup.in.hostname, *lookup.out.address); done: talloc_free(mem_ctx); @@ -115,9 +116,9 @@ done: } -BOOL torture_lookup_pdc(struct torture_context *torture) +bool torture_lookup_pdc(struct torture_context *torture) { - BOOL ret; + bool ret; NTSTATUS status; TALLOC_CTX *mem_ctx; struct libnet_context *ctx; @@ -133,11 +134,11 @@ BOOL torture_lookup_pdc(struct torture_context *torture) lookup = talloc(mem_ctx, struct libnet_LookupDCs); if (!lookup) { - ret = False; + ret = false; goto done; } - lookup->in.domain_name = lp_workgroup(); + lookup->in.domain_name = lp_workgroup(global_loadparm); lookup->in.name_type = NBT_NAME_PDC; status = libnet_LookupDCs(ctx, mem_ctx, lookup); @@ -145,11 +146,11 @@ BOOL torture_lookup_pdc(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { printf("Couldn't lookup pdc %s: %s\n", lookup->in.domain_name, nt_errstr(status)); - ret = False; + ret = false; goto done; } - ret = True; + ret = true; printf("DCs of domain [%s] found.\n", lookup->in.domain_name); for (i = 0; i < lookup->out.num_dcs; i++) { @@ -163,7 +164,7 @@ done: } -BOOL torture_lookup_sam_name(struct torture_context *torture) +bool torture_lookup_sam_name(struct torture_context *torture) { NTSTATUS status; TALLOC_CTX *mem_ctx; @@ -174,15 +175,15 @@ BOOL torture_lookup_sam_name(struct torture_context *torture) ctx->cred = cmdline_credentials; mem_ctx = talloc_init("torture lookup sam name"); - if (mem_ctx == NULL) return False; + if (mem_ctx == NULL) return false; r.in.name = "Administrator"; - r.in.domain_name = lp_workgroup(); + r.in.domain_name = lp_workgroup(global_loadparm); status = libnet_LookupName(ctx, mem_ctx, &r); talloc_free(mem_ctx); talloc_free(ctx); - return True; + return true; } diff --git a/source4/torture/libnet/libnet_rpc.c b/source4/torture/libnet/libnet_rpc.c index 07c586ebf3..5ca927a1e3 100644 --- a/source4/torture/libnet/libnet_rpc.c +++ b/source4/torture/libnet/libnet_rpc.c @@ -30,14 +30,15 @@ #include "librpc/rpc/dcerpc.h" #include "torture/rpc/rpc.h" #include "torture/torture.h" +#include "param/param.h" -static BOOL test_connect_service(struct libnet_context *ctx, +static bool test_connect_service(struct libnet_context *ctx, const struct ndr_interface_table *iface, const char *binding_string, const char *hostname, const enum libnet_RpcConnect_level level, - BOOL badcreds, NTSTATUS expected_status) + bool badcreds, NTSTATUS expected_status) { NTSTATUS status; struct libnet_RpcConnect connect; @@ -61,7 +62,7 @@ static BOOL test_connect_service(struct libnet_context *ctx, connect.in.dcerpc_iface->name, connect.in.binding, nt_errstr(expected_status), nt_errstr(status)); - return False; + return false; } d_printf("PASSED. Expected: %s, received: %s\n", nt_errstr(expected_status), @@ -78,11 +79,11 @@ static BOOL test_connect_service(struct libnet_context *ctx, d_printf("Error string: %s\n", connect.out.error_string); } - return True; + return true; } -static BOOL torture_rpc_connect(struct torture_context *torture, +static bool torture_rpc_connect(struct torture_context *torture, const enum libnet_RpcConnect_level level, const char *bindstr, const char *hostname) { @@ -93,46 +94,46 @@ static BOOL torture_rpc_connect(struct torture_context *torture, d_printf("Testing connection to LSA interface\n"); if (!test_connect_service(ctx, &ndr_table_lsarpc, bindstr, - hostname, level, False, NT_STATUS_OK)) { + hostname, level, false, NT_STATUS_OK)) { d_printf("failed to connect LSA interface\n"); - return False; + return false; } d_printf("Testing connection to SAMR interface\n"); if (!test_connect_service(ctx, &ndr_table_samr, bindstr, - hostname, level, False, NT_STATUS_OK)) { + hostname, level, false, NT_STATUS_OK)) { d_printf("failed to connect SAMR interface\n"); - return False; + return false; } d_printf("Testing connection to SRVSVC interface\n"); if (!test_connect_service(ctx, &ndr_table_srvsvc, bindstr, - hostname, level, False, NT_STATUS_OK)) { + hostname, level, false, NT_STATUS_OK)) { d_printf("failed to connect SRVSVC interface\n"); - return False; + return false; } d_printf("Testing connection to LSA interface with wrong credentials\n"); if (!test_connect_service(ctx, &ndr_table_lsarpc, bindstr, - hostname, level, True, NT_STATUS_LOGON_FAILURE)) { + hostname, level, true, NT_STATUS_LOGON_FAILURE)) { d_printf("failed to test wrong credentials on LSA interface\n"); - return False; + return false; } d_printf("Testing connection to SAMR interface with wrong credentials\n"); if (!test_connect_service(ctx, &ndr_table_samr, bindstr, - hostname, level, True, NT_STATUS_LOGON_FAILURE)) { + hostname, level, true, NT_STATUS_LOGON_FAILURE)) { d_printf("failed to test wrong credentials on SAMR interface\n"); - return False; + return false; } talloc_free(ctx); - return True; + return true; } -BOOL torture_rpc_connect_srv(struct torture_context *torture) +bool torture_rpc_connect_srv(struct torture_context *torture) { const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_SERVER; NTSTATUS status; @@ -140,14 +141,14 @@ BOOL torture_rpc_connect_srv(struct torture_context *torture) status = torture_rpc_binding(torture, &binding); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } return torture_rpc_connect(torture, level, NULL, binding->host); } -BOOL torture_rpc_connect_pdc(struct torture_context *torture) +bool torture_rpc_connect_pdc(struct torture_context *torture) { const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_PDC; NTSTATUS status; @@ -156,18 +157,18 @@ BOOL torture_rpc_connect_pdc(struct torture_context *torture) status = torture_rpc_binding(torture, &binding); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } /* we're accessing domain controller so the domain name should be passed (it's going to be resolved to dc name and address) instead of specific server name. */ - domain_name = lp_workgroup(); + domain_name = lp_workgroup(global_loadparm); return torture_rpc_connect(torture, level, NULL, domain_name); } -BOOL torture_rpc_connect_dc(struct torture_context *torture) +bool torture_rpc_connect_dc(struct torture_context *torture) { const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_DC; NTSTATUS status; @@ -176,18 +177,18 @@ BOOL torture_rpc_connect_dc(struct torture_context *torture) status = torture_rpc_binding(torture, &binding); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } /* we're accessing domain controller so the domain name should be passed (it's going to be resolved to dc name and address) instead of specific server name. */ - domain_name = lp_workgroup(); + domain_name = lp_workgroup(global_loadparm); return torture_rpc_connect(torture, level, NULL, domain_name); } -BOOL torture_rpc_connect_dc_info(struct torture_context *torture) +bool torture_rpc_connect_dc_info(struct torture_context *torture) { const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_DC_INFO; NTSTATUS status; @@ -196,18 +197,18 @@ BOOL torture_rpc_connect_dc_info(struct torture_context *torture) status = torture_rpc_binding(torture, &binding); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } /* we're accessing domain controller so the domain name should be passed (it's going to be resolved to dc name and address) instead of specific server name. */ - domain_name = lp_workgroup(); + domain_name = lp_workgroup(global_loadparm); return torture_rpc_connect(torture, level, NULL, domain_name); } -BOOL torture_rpc_connect_binding(struct torture_context *torture) +bool torture_rpc_connect_binding(struct torture_context *torture) { const enum libnet_RpcConnect_level level = LIBNET_RPC_CONNECT_BINDING; NTSTATUS status; @@ -216,7 +217,7 @@ BOOL torture_rpc_connect_binding(struct torture_context *torture) status = torture_rpc_binding(torture, &binding); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } bindstr = dcerpc_binding_string(torture, binding); diff --git a/source4/torture/libnet/libnet_share.c b/source4/torture/libnet/libnet_share.c index b6b0b37d01..d18e6ea9db 100644 --- a/source4/torture/libnet/libnet_share.c +++ b/source4/torture/libnet/libnet_share.c @@ -113,13 +113,13 @@ static void test_displayshares(struct libnet_ListShares s) } -BOOL torture_listshares(struct torture_context *torture) +bool torture_listshares(struct torture_context *torture) { struct libnet_ListShares share; NTSTATUS status; uint32_t levels[] = { 0, 1, 2, 501, 502 }; int i; - BOOL ret = True; + bool ret = true; struct libnet_context* libnetctx; struct dcerpc_binding *bind; TALLOC_CTX *mem_ctx; @@ -127,14 +127,14 @@ BOOL torture_listshares(struct torture_context *torture) mem_ctx = talloc_init("test_listshares"); status = torture_rpc_binding(torture, &bind); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto done; } libnetctx = libnet_context_init(NULL); if (!libnetctx) { printf("Couldn't allocate libnet context\n"); - ret = False; + ret = false; goto done; } @@ -151,7 +151,7 @@ BOOL torture_listshares(struct torture_context *torture) status = libnet_ListShares(libnetctx, mem_ctx, &share); if (!NT_STATUS_IS_OK(status)) { printf("libnet_ListShare level %u failed - %s\n", share.in.level, share.out.error_string); - ret = False; + ret = false; goto done; } @@ -165,7 +165,7 @@ done: } -static BOOL test_addshare(struct dcerpc_pipe *svc_pipe, TALLOC_CTX *mem_ctx, const char *host, +static bool test_addshare(struct dcerpc_pipe *svc_pipe, TALLOC_CTX *mem_ctx, const char *host, const char* share) { NTSTATUS status; @@ -187,32 +187,27 @@ static BOOL test_addshare(struct dcerpc_pipe *svc_pipe, TALLOC_CTX *mem_ctx, con status = dcerpc_srvsvc_NetShareAdd(svc_pipe, mem_ctx, &add); if (!NT_STATUS_IS_OK(status)) { printf("Failed to add a new share\n"); - return False; + return false; } printf("share added\n"); - return True; + return true; } -BOOL torture_delshare(struct torture_context *torture) +bool torture_delshare(struct torture_context *torture) { struct dcerpc_pipe *p; struct dcerpc_binding *bind; struct libnet_context* libnetctx; const char *host; - TALLOC_CTX *mem_ctx; NTSTATUS status; - BOOL ret = True; + bool ret = true; struct libnet_DelShare share; - mem_ctx = talloc_init("test_listshares"); host = torture_setting_string(torture, "host", NULL); status = torture_rpc_binding(torture, &bind); - if (!NT_STATUS_IS_OK(status)) { - ret = False; - goto done; - } + torture_assert_ntstatus_ok(torture, status, "Failed to get binding"); libnetctx = libnet_context_init(NULL); libnetctx->cred = cmdline_credentials; @@ -221,22 +216,15 @@ BOOL torture_delshare(struct torture_context *torture) &p, &ndr_table_srvsvc); - if (!test_addshare(p, mem_ctx, host, TEST_SHARENAME)) { - ret = False; - goto done; + if (!test_addshare(p, torture, host, TEST_SHARENAME)) { + return false; } share.in.server_name = bind->host; share.in.share_name = TEST_SHARENAME; - status = libnet_DelShare(libnetctx, mem_ctx, &share); - if (!NT_STATUS_IS_OK(status)) { - ret = False; - goto done; - } + status = libnet_DelShare(libnetctx, torture, &share); + torture_assert_ntstatus_ok(torture, status, "Failed to delete share"); - -done: - talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/libnet/libnet_user.c b/source4/torture/libnet/libnet_user.c index 7a3b9f19c1..b3aadc776e 100644 --- a/source4/torture/libnet/libnet_user.c +++ b/source4/torture/libnet/libnet_user.c @@ -27,9 +27,10 @@ #include "torture/torture.h" #include "torture/rpc/rpc.h" #include "torture/libnet/usertest.h" +#include "param/param.h" -static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, const char *username) { NTSTATUS status; @@ -51,7 +52,7 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupNames(p, mem_ctx, &r1); if (!NT_STATUS_IS_OK(status)) { printf("LookupNames failed - %s\n", nt_errstr(status)); - return False; + return false; } rid = r1.out.rids.ids[0]; @@ -66,7 +67,7 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenUser(p, mem_ctx, &r2); if (!NT_STATUS_IS_OK(status)) { printf("OpenUser failed - %s\n", nt_errstr(status)); - return False; + return false; } r3.in.user_handle = &user_handle; @@ -77,14 +78,14 @@ static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3); if (!NT_STATUS_IS_OK(status)) { printf("DeleteUser failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *domname) { NTSTATUS status; @@ -102,7 +103,7 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Connect(p, mem_ctx, &r1); if (!NT_STATUS_IS_OK(status)) { printf("Connect failed - %s\n", nt_errstr(status)); - return False; + return false; } r2.in.connect_handle = &h; @@ -113,7 +114,7 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2); if (!NT_STATUS_IS_OK(status)) { printf("LookupDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } r3.in.connect_handle = &h; @@ -126,16 +127,16 @@ static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3); if (!NT_STATUS_IS_OK(status)) { printf("OpenDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } else { *handle = domain_handle; } - return True; + return true; } -static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { NTSTATUS status; @@ -147,14 +148,14 @@ static BOOL test_samr_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Close(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Close samr domain failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_lsa_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_lsa_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { NTSTATUS status; @@ -166,14 +167,14 @@ static BOOL test_lsa_close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_lsa_Close(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Close lsa domain failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char* user) { NTSTATUS status; @@ -200,7 +201,7 @@ static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { printf("User (%s) already exists - attempting to delete and recreate account again\n", user); if (!test_cleanup(p, mem_ctx, handle, TEST_USERNAME)) { - return False; + return false; } printf("creating user account\n"); @@ -208,11 +209,11 @@ static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_CreateUser(p, mem_ctx, &r1); if (!NT_STATUS_IS_OK(status)) { printf("CreateUser failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } - return False; + return false; } r2.in.handle = &user_handle; @@ -223,20 +224,20 @@ static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Close(p, mem_ctx, &r2); if (!NT_STATUS_IS_OK(status)) { printf("Close failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -BOOL torture_createuser(struct torture_context *torture) +bool torture_createuser(struct torture_context *torture) { NTSTATUS status; TALLOC_CTX *mem_ctx; struct libnet_context *ctx; struct libnet_CreateUser req; - BOOL ret = True; + bool ret = true; mem_ctx = talloc_init("test_createuser"); @@ -244,25 +245,25 @@ BOOL torture_createuser(struct torture_context *torture) ctx->cred = cmdline_credentials; req.in.user_name = TEST_USERNAME; - req.in.domain_name = lp_workgroup(); + req.in.domain_name = lp_workgroup(global_loadparm); req.out.error_string = NULL; status = libnet_CreateUser(ctx, mem_ctx, &req); if (!NT_STATUS_IS_OK(status)) { printf("libnet_CreateUser call failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) { printf("cleanup failed\n"); - ret = False; + ret = false; goto done; } if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { printf("domain close failed\n"); - ret = False; + ret = false; } done: @@ -272,7 +273,7 @@ done: } -BOOL torture_deleteuser(struct torture_context *torture) +bool torture_deleteuser(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; @@ -282,7 +283,7 @@ BOOL torture_deleteuser(struct torture_context *torture) const char *name = TEST_USERNAME; struct libnet_context *ctx; struct libnet_DeleteUser req; - BOOL ret = True; + bool ret = true; prep_mem_ctx = talloc_init("prepare test_deleteuser"); @@ -290,24 +291,24 @@ BOOL torture_deleteuser(struct torture_context *torture) ctx->cred = cmdline_credentials; req.in.user_name = TEST_USERNAME; - req.in.domain_name = lp_workgroup(); + req.in.domain_name = lp_workgroup(global_loadparm); status = torture_rpc_connection(torture, &p, &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto done; } - domain_name.string = lp_workgroup(); + domain_name.string = lp_workgroup(global_loadparm); if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) { - ret = False; + ret = false; goto done; } if (!test_createuser(p, prep_mem_ctx, &h, name)) { - ret = False; + ret = false; goto done; } @@ -316,7 +317,7 @@ BOOL torture_deleteuser(struct torture_context *torture) status = libnet_DeleteUser(ctx, mem_ctx, &req); if (!NT_STATUS_IS_OK(status)) { printf("libnet_DeleteUser call failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; } talloc_free(mem_ctx); @@ -417,7 +418,7 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, case acct_expiry: continue_if_field_set(r->in.acct_expiry); now = timeval_add(&now, (random() % (31*24*60*60)), 0); - r->in.acct_expiry = talloc_memdup(mem_ctx, &now, sizeof(now)); + r->in.acct_expiry = (struct timeval *)talloc_memdup(mem_ctx, &now, sizeof(now)); fldname = "acct_expiry"; break; @@ -438,26 +439,26 @@ static void set_test_changes(TALLOC_CTX *mem_ctx, struct libnet_ModifyUser *r, #define TEST_STR_FLD(fld) \ if (!strequal(req.in.fld, user_req.out.fld)) { \ printf("failed to change '%s'\n", #fld); \ - ret = False; \ + ret = false; \ goto cleanup; \ } #define TEST_TIME_FLD(fld) \ if (timeval_compare(req.in.fld, user_req.out.fld)) { \ printf("failed to change '%s'\n", #fld); \ - ret = False; \ + ret = false; \ goto cleanup; \ } #define TEST_NUM_FLD(fld) \ if (req.in.fld != user_req.out.fld) { \ printf("failed to change '%s'\n", #fld); \ - ret = False; \ + ret = false; \ goto cleanup; \ } -BOOL torture_modifyuser(struct torture_context *torture) +bool torture_modifyuser(struct torture_context *torture) { NTSTATUS status; struct dcerpc_binding *bind; @@ -470,7 +471,7 @@ BOOL torture_modifyuser(struct torture_context *torture) struct libnet_ModifyUser req; struct libnet_UserInfo user_req; int fld; - BOOL ret = True; + bool ret = true; prep_mem_ctx = talloc_init("prepare test_deleteuser"); @@ -481,20 +482,20 @@ BOOL torture_modifyuser(struct torture_context *torture) &p, &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto done; } name = talloc_strdup(prep_mem_ctx, TEST_USERNAME); - domain_name.string = lp_workgroup(); + domain_name.string = lp_workgroup(global_loadparm); if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) { - ret = False; + ret = false; goto done; } if (!test_createuser(p, prep_mem_ctx, &h, name)) { - ret = False; + ret = false; goto done; } @@ -502,7 +503,7 @@ BOOL torture_modifyuser(struct torture_context *torture) status = torture_rpc_binding(mem_ctx, &bind); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto done; } @@ -510,7 +511,7 @@ BOOL torture_modifyuser(struct torture_context *torture) for (fld = 1; fld < FIELDS_NUM - 1; fld++) { ZERO_STRUCT(req); - req.in.domain_name = lp_workgroup(); + req.in.domain_name = lp_workgroup(global_loadparm); req.in.user_name = name; set_test_changes(mem_ctx, &req, 1, &name, fld); @@ -518,18 +519,18 @@ BOOL torture_modifyuser(struct torture_context *torture) status = libnet_ModifyUser(ctx, mem_ctx, &req); if (!NT_STATUS_IS_OK(status)) { printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; continue; } ZERO_STRUCT(user_req); - user_req.in.domain_name = lp_workgroup(); + user_req.in.domain_name = lp_workgroup(global_loadparm); user_req.in.user_name = name; status = libnet_UserInfo(ctx, mem_ctx, &user_req); if (!NT_STATUS_IS_OK(status)) { printf("libnet_UserInfo call failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; continue; } @@ -562,7 +563,7 @@ BOOL torture_modifyuser(struct torture_context *torture) /* restore original testing username - it's useful when test fails because it prevents from problems with recreating account */ ZERO_STRUCT(req); - req.in.domain_name = lp_workgroup(); + req.in.domain_name = lp_workgroup(global_loadparm); req.in.user_name = name; req.in.account_name = TEST_USERNAME; @@ -570,7 +571,7 @@ BOOL torture_modifyuser(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { printf("libnet_ModifyUser call failed: %s\n", nt_errstr(status)); talloc_free(mem_ctx); - ret = False; + ret = false; goto done; } @@ -581,13 +582,13 @@ BOOL torture_modifyuser(struct torture_context *torture) cleanup: if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, name)) { printf("cleanup failed\n"); - ret = False; + ret = false; goto done; } if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { printf("domain close failed\n"); - ret = False; + ret = false; } talloc_free(mem_ctx); @@ -599,10 +600,10 @@ done: } -BOOL torture_userinfo_api(struct torture_context *torture) +bool torture_userinfo_api(struct torture_context *torture) { const char *name = TEST_USERNAME; - BOOL ret = True; + bool ret = true; NTSTATUS status; TALLOC_CTX *mem_ctx = NULL, *prep_mem_ctx; struct libnet_context *ctx; @@ -620,17 +621,17 @@ BOOL torture_userinfo_api(struct torture_context *torture) &p, &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } - domain_name.string = lp_workgroup(); + domain_name.string = lp_workgroup(global_loadparm); if (!test_opendomain(p, prep_mem_ctx, &h, &domain_name)) { - ret = False; + ret = false; goto done; } if (!test_createuser(p, prep_mem_ctx, &h, name)) { - ret = False; + ret = false; goto done; } @@ -644,20 +645,20 @@ BOOL torture_userinfo_api(struct torture_context *torture) status = libnet_UserInfo(ctx, mem_ctx, &req); if (!NT_STATUS_IS_OK(status)) { printf("libnet_UserInfo call failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; talloc_free(mem_ctx); goto done; } if (!test_cleanup(ctx->samr.pipe, mem_ctx, &ctx->samr.handle, TEST_USERNAME)) { printf("cleanup failed\n"); - ret = False; + ret = false; goto done; } if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { printf("domain close failed\n"); - ret = False; + ret = false; } talloc_free(ctx); @@ -668,9 +669,9 @@ done: } -BOOL torture_userlist(struct torture_context *torture) +bool torture_userlist(struct torture_context *torture) { - BOOL ret = True; + bool ret = true; NTSTATUS status; TALLOC_CTX *mem_ctx = NULL; struct libnet_context *ctx; @@ -681,7 +682,7 @@ BOOL torture_userlist(struct torture_context *torture) ctx = libnet_context_init(NULL); ctx->cred = cmdline_credentials; - domain_name.string = lp_workgroup(); + domain_name.string = lp_workgroup(global_loadparm); mem_ctx = talloc_init("torture user list"); ZERO_STRUCT(req); @@ -706,19 +707,19 @@ BOOL torture_userlist(struct torture_context *torture) if (!(NT_STATUS_IS_OK(status) || NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES))) { printf("libnet_UserList call failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } if (!test_samr_close(ctx->samr.pipe, mem_ctx, &ctx->samr.handle)) { printf("samr domain close failed\n"); - ret = False; + ret = false; goto done; } if (!test_lsa_close(ctx->lsa.pipe, mem_ctx, &ctx->lsa.handle)) { printf("lsa domain close failed\n"); - ret = False; + ret = false; } talloc_free(ctx); diff --git a/source4/torture/libnet/userinfo.c b/source4/torture/libnet/userinfo.c index ad35e84861..46a9a6a015 100644 --- a/source4/torture/libnet/userinfo.c +++ b/source4/torture/libnet/userinfo.c @@ -23,162 +23,13 @@ #include "libnet/libnet.h" #include "libcli/security/security.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "param/param.h" +#include "torture/libnet/utils.h" -#define TEST_USERNAME "libnetuserinfotest" - -static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, struct lsa_String *domname, - struct dom_sid2 *sid) -{ - NTSTATUS status; - struct policy_handle h, domain_handle; - struct samr_Connect r1; - struct samr_LookupDomain r2; - struct samr_OpenDomain r3; - - printf("connecting\n"); - - r1.in.system_name = 0; - r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r1.out.connect_handle = &h; - - status = dcerpc_samr_Connect(p, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - printf("Connect failed - %s\n", nt_errstr(status)); - return False; - } - - r2.in.connect_handle = &h; - r2.in.domain_name = domname; - - printf("domain lookup on %s\n", domname->string); - - status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - printf("LookupDomain failed - %s\n", nt_errstr(status)); - return False; - } - - r3.in.connect_handle = &h; - r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r3.in.sid = r2.out.sid; - r3.out.domain_handle = &domain_handle; - - printf("opening domain\n"); - - status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenDomain failed - %s\n", nt_errstr(status)); - return False; - } else { - *handle = domain_handle; - } - - *sid = *r2.out.sid; - return True; -} - - -static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *domain_handle, const char *username) -{ - NTSTATUS status; - struct samr_LookupNames r1; - struct samr_OpenUser r2; - struct samr_DeleteUser r3; - struct lsa_String names[2]; - uint32_t rid; - struct policy_handle user_handle; - - names[0].string = username; - - r1.in.domain_handle = domain_handle; - r1.in.num_names = 1; - r1.in.names = names; - - printf("user account lookup '%s'\n", username); - - status = dcerpc_samr_LookupNames(p, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - printf("LookupNames failed - %s\n", nt_errstr(status)); - return False; - } - - rid = r1.out.rids.ids[0]; - - r2.in.domain_handle = domain_handle; - r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r2.in.rid = rid; - r2.out.user_handle = &user_handle; - - printf("opening user account\n"); - - status = dcerpc_samr_OpenUser(p, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenUser failed - %s\n", nt_errstr(status)); - return False; - } - - r3.in.user_handle = &user_handle; - r3.out.user_handle = &user_handle; - - printf("deleting user account\n"); - - status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - printf("DeleteUser failed - %s\n", nt_errstr(status)); - return False; - } - - return True; -} - - -static BOOL test_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, const char *name, uint32_t *rid) -{ - NTSTATUS status; - struct lsa_String username; - struct samr_CreateUser r; - struct policy_handle user_handle; - - username.string = name; - - r.in.domain_handle = handle; - r.in.account_name = &username; - r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r.out.user_handle = &user_handle; - r.out.rid = rid; - - printf("creating user account %s\n", name); - - status = dcerpc_samr_CreateUser(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("CreateUser failed - %s\n", nt_errstr(status)); - - if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { - printf("User (%s) already exists - attempting to delete and recreate account again\n", name); - if (!test_cleanup(p, mem_ctx, handle, TEST_USERNAME)) { - return False; - } - - printf("creating user account\n"); - - status = dcerpc_samr_CreateUser(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("CreateUser failed - %s\n", nt_errstr(status)); - return False; - } - return True; - } - return False; - } - - return True; -} +#define TEST_USERNAME "libnetuserinfotest" -static BOOL test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, struct dom_sid2 *domain_sid, const char* user_name, uint32_t *rid) @@ -198,7 +49,7 @@ static BOOL test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = libnet_rpc_userinfo(p, mem_ctx, &user); if (!NT_STATUS_IS_OK(status)) { printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status)); - return False; + return false; } ZERO_STRUCT(user); @@ -212,38 +63,14 @@ static BOOL test_userinfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = libnet_rpc_userinfo(p, mem_ctx, &user); if (!NT_STATUS_IS_OK(status)) { printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status)); - return False; + return false; } - return True; -} - - -static void msg_handler(struct monitor_msg *m) -{ - struct msg_rpc_open_user *msg_open; - struct msg_rpc_query_user *msg_query; - struct msg_rpc_close_user *msg_close; - - switch (m->type) { - case mon_SamrOpenUser: - msg_open = (struct msg_rpc_open_user*)m->data; - printf("monitor_msg: user opened (rid=%d, access_mask=0x%08x)\n", - msg_open->rid, msg_open->access_mask); - break; - case mon_SamrQueryUser: - msg_query = (struct msg_rpc_query_user*)m->data; - printf("monitor_msg: user queried (level=%d)\n", msg_query->level); - break; - case mon_SamrCloseUser: - msg_close = (struct msg_rpc_close_user*)m->data; - printf("monitor_msg: user closed (rid=%d)\n", msg_close->rid); - break; - } + return true; } -static BOOL test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, struct dom_sid2 *domain_sid, const char* user_name, uint32_t *rid) @@ -265,13 +92,13 @@ static BOOL test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c = libnet_rpc_userinfo_send(p, &user, msg_handler); if (!c) { printf("Failed to call sync libnet_rpc_userinfo_send\n"); - return False; + return false; } status = libnet_rpc_userinfo_recv(c, mem_ctx, &user); if (!NT_STATUS_IS_OK(status)) { printf("Calling async libnet_rpc_userinfo failed - %s\n", nt_errstr(status)); - return False; + return false; } ZERO_STRUCT(user); @@ -286,25 +113,25 @@ static BOOL test_userinfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c = libnet_rpc_userinfo_send(p, &user, msg_handler); if (!c) { printf("Failed to call sync libnet_rpc_userinfo_send\n"); - return False; + return false; } status = libnet_rpc_userinfo_recv(c, mem_ctx, &user); if (!NT_STATUS_IS_OK(status)) { printf("Calling async libnet_rpc_userinfo failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -BOOL torture_userinfo(struct torture_context *torture) +bool torture_userinfo(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct policy_handle h; struct lsa_String name; struct dom_sid2 sid; @@ -317,31 +144,31 @@ BOOL torture_userinfo(struct torture_context *torture) &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } - name.string = lp_workgroup(); + name.string = lp_workgroup(global_loadparm); /* * Testing synchronous version */ if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) { - ret = False; + ret = false; goto done; } - if (!test_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) { - ret = False; + if (!test_user_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) { + ret = false; goto done; } if (!test_userinfo(p, mem_ctx, &h, &sid, TEST_USERNAME, &rid)) { - ret = False; + ret = false; goto done; } - if (!test_cleanup(p, mem_ctx, &h, TEST_USERNAME)) { - ret = False; + if (!test_user_cleanup(p, mem_ctx, &h, TEST_USERNAME)) { + ret = false; goto done; } @@ -349,22 +176,22 @@ BOOL torture_userinfo(struct torture_context *torture) * Testing asynchronous version and monitor messages */ if (!test_opendomain(p, mem_ctx, &h, &name, &sid)) { - ret = False; + ret = false; goto done; } - if (!test_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) { - ret = False; + if (!test_user_create(p, mem_ctx, &h, TEST_USERNAME, &rid)) { + ret = false; goto done; } if (!test_userinfo_async(p, mem_ctx, &h, &sid, TEST_USERNAME, &rid)) { - ret = False; + ret = false; goto done; } - if (!test_cleanup(p, mem_ctx, &h, TEST_USERNAME)) { - ret = False; + if (!test_user_cleanup(p, mem_ctx, &h, TEST_USERNAME)) { + ret = false; goto done; } diff --git a/source4/torture/libnet/userman.c b/source4/torture/libnet/userman.c index 90b3f41959..e834938bc5 100644 --- a/source4/torture/libnet/userman.c +++ b/source4/torture/libnet/userman.c @@ -23,65 +23,17 @@ #include "torture/libnet/usertest.h" #include "libnet/libnet.h" #include "librpc/gen_ndr/ndr_samr_c.h" +#include "param/param.h" +#include "torture/libnet/utils.h" -static BOOL test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, struct lsa_String *domname) -{ - NTSTATUS status; - struct policy_handle h, domain_handle; - struct samr_Connect r1; - struct samr_LookupDomain r2; - struct samr_OpenDomain r3; - - printf("connecting\n"); - - r1.in.system_name = 0; - r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r1.out.connect_handle = &h; - - status = dcerpc_samr_Connect(p, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - printf("Connect failed - %s\n", nt_errstr(status)); - return False; - } - - r2.in.connect_handle = &h; - r2.in.domain_name = domname; - - printf("domain lookup on %s\n", domname->string); - - status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - printf("LookupDomain failed - %s\n", nt_errstr(status)); - return False; - } - - r3.in.connect_handle = &h; - r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r3.in.sid = r2.out.sid; - r3.out.domain_handle = &domain_handle; - - printf("opening domain\n"); - - status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenDomain failed - %s\n", nt_errstr(status)); - return False; - } else { - *handle = domain_handle; - } - - return True; -} - -static BOOL test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, const char *name) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct libnet_rpc_useradd user; user.in.domain_handle = *domain_handle; @@ -91,28 +43,15 @@ static BOOL test_useradd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = libnet_rpc_useradd(p, mem_ctx, &user); if (!NT_STATUS_IS_OK(status)) { - printf("Failed to call sync rpc_composite_userinfo - %s\n", nt_errstr(status)); - return False; + printf("Failed to call libnet_rpc_useradd - %s\n", nt_errstr(status)); + return false; } return ret; } -static void msg_handler(struct monitor_msg *m) -{ - struct msg_rpc_create_user *msg_create; - - switch (m->type) { - case mon_SamrCreateUser: - msg_create = (struct msg_rpc_create_user*)m->data; - printf("monitor_msg: user created (rid=%d)\n", msg_create->rid); - break; - } -} - - -static BOOL test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char* username) { NTSTATUS status; @@ -127,133 +66,20 @@ static BOOL test_useradd_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c = libnet_rpc_useradd_send(p, &user, msg_handler); if (!c) { printf("Failed to call async libnet_rpc_useradd\n"); - return False; + return false; } status = libnet_rpc_useradd_recv(c, mem_ctx, &user); if (!NT_STATUS_IS_OK(status)) { printf("Calling async libnet_rpc_useradd failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } - -static BOOL test_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *domain_handle, const char *username) -{ - NTSTATUS status; - struct samr_LookupNames r1; - struct samr_OpenUser r2; - struct samr_DeleteUser r3; - struct lsa_String names[2]; - uint32_t rid; - struct policy_handle user_handle; - - names[0].string = username; - - r1.in.domain_handle = domain_handle; - r1.in.num_names = 1; - r1.in.names = names; - - printf("user account lookup '%s'\n", username); - - status = dcerpc_samr_LookupNames(p, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - printf("LookupNames failed - %s\n", nt_errstr(status)); - return False; - } - - rid = r1.out.rids.ids[0]; - - r2.in.domain_handle = domain_handle; - r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r2.in.rid = rid; - r2.out.user_handle = &user_handle; - - printf("opening user account\n"); - - status = dcerpc_samr_OpenUser(p, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenUser failed - %s\n", nt_errstr(status)); - return False; - } - - r3.in.user_handle = &user_handle; - r3.out.user_handle = &user_handle; - - printf("deleting user account\n"); - - status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - printf("DeleteUser failed - %s\n", nt_errstr(status)); - return False; - } - - return True; -} - - -static BOOL test_createuser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, const char* user) -{ - NTSTATUS status; - struct policy_handle user_handle; - struct lsa_String username; - struct samr_CreateUser r1; - struct samr_Close r2; - uint32_t user_rid; - - username.string = user; - - r1.in.domain_handle = handle; - r1.in.account_name = &username; - r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - r1.out.user_handle = &user_handle; - r1.out.rid = &user_rid; - - printf("creating user '%s'\n", username.string); - - status = dcerpc_samr_CreateUser(p, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - printf("CreateUser failed - %s\n", nt_errstr(status)); - - if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { - printf("User (%s) already exists - attempting to delete and recreate account again\n", user); - if (!test_cleanup(p, mem_ctx, handle, TEST_USERNAME)) { - return False; - } - - printf("creating user account\n"); - - status = dcerpc_samr_CreateUser(p, mem_ctx, &r1); - if (!NT_STATUS_IS_OK(status)) { - printf("CreateUser failed - %s\n", nt_errstr(status)); - return False; - } - return True; - } - return False; - } - - r2.in.handle = &user_handle; - r2.out.handle = &user_handle; - - printf("closing user '%s'\n", username.string); - - status = dcerpc_samr_Close(p, mem_ctx, &r2); - if (!NT_STATUS_IS_OK(status)) { - printf("Close failed - %s\n", nt_errstr(status)); - return False; - } - - return True; -} - - -static BOOL test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, int num_changes, struct libnet_rpc_usermod *mod, char **username) { @@ -356,7 +182,7 @@ static BOOL test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, case acct_expiry: continue_if_field_set(mod->in.change.acct_expiry); now = timeval_add(&now, (random() % (31*24*60*60)), 0); - mod->in.change.acct_expiry = talloc_memdup(mem_ctx, &now, sizeof(now)); + mod->in.change.acct_expiry = (struct timeval *)talloc_memdup(mem_ctx, &now, sizeof(now)); mod->in.change.fields |= USERMOD_FIELD_ACCT_EXPIRY; fldname = "acct_expiry"; break; @@ -380,14 +206,14 @@ static BOOL test_usermod(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = libnet_rpc_usermod(p, mem_ctx, mod); if (!NT_STATUS_IS_OK(status)) { printf("Failed to call sync libnet_rpc_usermod - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char *username) { NTSTATUS status; @@ -399,10 +225,10 @@ static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = libnet_rpc_userdel(p, mem_ctx, &user); if (!NT_STATUS_IS_OK(status)) { printf("Failed to call sync libnet_rpc_userdel - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } @@ -412,7 +238,7 @@ static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("'%s' field does not match\n", #fld); \ printf("received: '%s'\n", i->fld.string); \ printf("expected: '%s'\n", mod->in.change.fld); \ - return False; \ + return false; \ } @@ -421,9 +247,12 @@ static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, nttime_to_timeval(&t, i->fld); \ if (timeval_compare(&t, mod->in.change.fld)) { \ printf("'%s' field does not match\n", #fld); \ - printf("received: '%s (+%ld us)'\n", timestring(mem_ctx, t.tv_sec), t.tv_usec); \ - printf("expected: '%s (+%ld us)'\n", timestring(mem_ctx, mod->in.change.fld->tv_sec), mod->in.change.fld->tv_usec); \ - return False; \ + printf("received: '%s (+%ld us)'\n", \ + timestring(mem_ctx, t.tv_sec), t.tv_usec); \ + printf("expected: '%s (+%ld us)'\n", \ + timestring(mem_ctx, mod->in.change.fld->tv_sec), \ + mod->in.change.fld->tv_usec); \ + return false; \ } \ } @@ -433,11 +262,11 @@ static BOOL test_userdel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("'%s' field does not match\n", #fld); \ printf("received: '%04x'\n", i->fld); \ printf("expected: '%04x'\n", mod->in.change.fld); \ - return False; \ + return false; \ } -static BOOL test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct libnet_rpc_usermod *mod, const char *username) { @@ -455,7 +284,7 @@ static BOOL test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = libnet_rpc_userinfo(p, mem_ctx, &info); if (!NT_STATUS_IS_OK(status)) { printf("Failed to call sync libnet_rpc_userinfo - %s\n", nt_errstr(status)); - return False; + return false; } i = &info.out.info.info21; @@ -471,19 +300,20 @@ static BOOL test_compare(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, CMP_TIME_FLD(acct_expiry, USERMOD_FIELD_ACCT_EXPIRY); CMP_NUM_FLD(acct_flags, USERMOD_FIELD_ACCT_FLAGS) - return True; + return true; } -BOOL torture_useradd(struct torture_context *torture) +bool torture_useradd(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; struct policy_handle h; struct lsa_String domain_name; + struct dom_sid2 sid; const char *name = TEST_USERNAME; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; mem_ctx = talloc_init("test_useradd"); @@ -492,37 +322,37 @@ BOOL torture_useradd(struct torture_context *torture) &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } - domain_name.string = lp_workgroup(); - if (!test_opendomain(p, mem_ctx, &h, &domain_name)) { - ret = False; + domain_name.string = lp_workgroup(global_loadparm); + if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) { + ret = false; goto done; } if (!test_useradd(p, mem_ctx, &h, name)) { - ret = False; + ret = false; goto done; } - if (!test_cleanup(p, mem_ctx, &h, name)) { - ret = False; + if (!test_user_cleanup(p, mem_ctx, &h, name)) { + ret = false; goto done; } - if (!test_opendomain(p, mem_ctx, &h, &domain_name)) { - ret = False; + if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) { + ret = false; goto done; } if (!test_useradd_async(p, mem_ctx, &h, name)) { - ret = False; + ret = false; goto done; } - if (!test_cleanup(p, mem_ctx, &h, name)) { - ret = False; + if (!test_user_cleanup(p, mem_ctx, &h, name)) { + ret = false; goto done; } @@ -532,15 +362,17 @@ done: } -BOOL torture_userdel(struct torture_context *torture) +bool torture_userdel(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; struct policy_handle h; struct lsa_String domain_name; + struct dom_sid2 sid; + uint32_t rid; const char *name = TEST_USERNAME; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; mem_ctx = talloc_init("test_userdel"); @@ -549,22 +381,22 @@ BOOL torture_userdel(struct torture_context *torture) &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } - domain_name.string = lp_workgroup(); - if (!test_opendomain(p, mem_ctx, &h, &domain_name)) { - ret = False; + domain_name.string = lp_workgroup(global_loadparm); + if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) { + ret = false; goto done; } - if (!test_createuser(p, mem_ctx, &h, name)) { - ret = False; + if (!test_user_create(p, mem_ctx, &h, name, &rid)) { + ret = false; goto done; } if (!test_userdel(p, mem_ctx, &h, name)) { - ret = False; + ret = false; goto done; } @@ -574,16 +406,18 @@ done: } -BOOL torture_usermod(struct torture_context *torture) +bool torture_usermod(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; struct policy_handle h; struct lsa_String domain_name; + struct dom_sid2 sid; + uint32_t rid; int i; char *name; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; mem_ctx = talloc_init("test_userdel"); @@ -592,20 +426,20 @@ BOOL torture_usermod(struct torture_context *torture) &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto done; } - domain_name.string = lp_workgroup(); + domain_name.string = lp_workgroup(global_loadparm); name = talloc_strdup(mem_ctx, TEST_USERNAME); - if (!test_opendomain(p, mem_ctx, &h, &domain_name)) { - ret = False; + if (!test_opendomain(p, mem_ctx, &h, &domain_name, &sid)) { + ret = false; goto done; } - if (!test_createuser(p, mem_ctx, &h, name)) { - ret = False; + if (!test_user_create(p, mem_ctx, &h, name, &rid)) { + ret = false; goto done; } @@ -613,19 +447,19 @@ BOOL torture_usermod(struct torture_context *torture) struct libnet_rpc_usermod m; if (!test_usermod(p, mem_ctx, &h, i, &m, &name)) { - ret = False; + ret = false; goto cleanup; } if (!test_compare(p, mem_ctx, &h, &m, name)) { - ret = False; + ret = false; goto cleanup; } } cleanup: - if (!test_cleanup(p, mem_ctx, &h, name)) { - ret = False; + if (!test_user_cleanup(p, mem_ctx, &h, name)) { + ret = false; goto done; } diff --git a/source4/torture/libnet/utils.c b/source4/torture/libnet/utils.c new file mode 100644 index 0000000000..47bb9315c7 --- /dev/null +++ b/source4/torture/libnet/utils.c @@ -0,0 +1,313 @@ +/* + Unix SMB/CIFS implementation. + Test suite for libnet calls. + + Copyright (C) Rafal Szczesniak 2007 + + 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/>. +*/ + +/* + * These are more general use functions shared among the tests. + */ + +#include "includes.h" +#include "torture/rpc/rpc.h" +#include "libnet/libnet.h" +#include "librpc/gen_ndr/ndr_samr_c.h" +#include "param/param.h" + + +bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, struct lsa_String *domname, + struct dom_sid2 *sid) +{ + NTSTATUS status; + struct policy_handle h, domain_handle; + struct samr_Connect r1; + struct samr_LookupDomain r2; + struct samr_OpenDomain r3; + + printf("connecting\n"); + + r1.in.system_name = 0; + r1.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + r1.out.connect_handle = &h; + + status = dcerpc_samr_Connect(p, mem_ctx, &r1); + if (!NT_STATUS_IS_OK(status)) { + printf("Connect failed - %s\n", nt_errstr(status)); + return false; + } + + r2.in.connect_handle = &h; + r2.in.domain_name = domname; + + printf("domain lookup on %s\n", domname->string); + + status = dcerpc_samr_LookupDomain(p, mem_ctx, &r2); + if (!NT_STATUS_IS_OK(status)) { + printf("LookupDomain failed - %s\n", nt_errstr(status)); + return false; + } + + r3.in.connect_handle = &h; + r3.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + r3.in.sid = r2.out.sid; + r3.out.domain_handle = &domain_handle; + + printf("opening domain\n"); + + status = dcerpc_samr_OpenDomain(p, mem_ctx, &r3); + if (!NT_STATUS_IS_OK(status)) { + printf("OpenDomain failed - %s\n", nt_errstr(status)); + return false; + } else { + *handle = domain_handle; + } + + *sid = *r2.out.sid; + return true; +} + + +bool test_user_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *domain_handle, + const char *name) +{ + NTSTATUS status; + struct samr_LookupNames r1; + struct samr_OpenUser r2; + struct samr_DeleteUser r3; + struct lsa_String names[2]; + uint32_t rid; + struct policy_handle user_handle; + + names[0].string = name; + + r1.in.domain_handle = domain_handle; + r1.in.num_names = 1; + r1.in.names = names; + + printf("user account lookup '%s'\n", name); + + status = dcerpc_samr_LookupNames(p, mem_ctx, &r1); + if (!NT_STATUS_IS_OK(status)) { + printf("LookupNames failed - %s\n", nt_errstr(status)); + return false; + } + + rid = r1.out.rids.ids[0]; + + r2.in.domain_handle = domain_handle; + r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + r2.in.rid = rid; + r2.out.user_handle = &user_handle; + + printf("opening user account\n"); + + status = dcerpc_samr_OpenUser(p, mem_ctx, &r2); + if (!NT_STATUS_IS_OK(status)) { + printf("OpenUser failed - %s\n", nt_errstr(status)); + return false; + } + + r3.in.user_handle = &user_handle; + r3.out.user_handle = &user_handle; + + printf("deleting user account\n"); + + status = dcerpc_samr_DeleteUser(p, mem_ctx, &r3); + if (!NT_STATUS_IS_OK(status)) { + printf("DeleteUser failed - %s\n", nt_errstr(status)); + return false; + } + + return true; +} + + +bool test_user_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, const char *name, + uint32_t *rid) +{ + NTSTATUS status; + struct lsa_String username; + struct samr_CreateUser r; + struct policy_handle user_handle; + + username.string = name; + + r.in.domain_handle = handle; + r.in.account_name = &username; + r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + r.out.user_handle = &user_handle; + r.out.rid = rid; + + printf("creating user account %s\n", name); + + status = dcerpc_samr_CreateUser(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("CreateUser failed - %s\n", nt_errstr(status)); + + if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { + printf("User (%s) already exists - attempting to delete and recreate account again\n", name); + if (!test_user_cleanup(p, mem_ctx, handle, name)) { + return false; + } + + printf("creating user account\n"); + + status = dcerpc_samr_CreateUser(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("CreateUser failed - %s\n", nt_errstr(status)); + return false; + } + return true; + } + return false; + } + + return true; +} + + +bool test_group_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *domain_handle, + const char *name) +{ + NTSTATUS status; + struct samr_LookupNames r1; + struct samr_OpenGroup r2; + struct samr_DeleteDomainGroup r3; + struct lsa_String names[2]; + uint32_t rid; + struct policy_handle group_handle; + + names[0].string = name; + + r1.in.domain_handle = domain_handle; + r1.in.num_names = 1; + r1.in.names = names; + + printf("group account lookup '%s'\n", name); + + status = dcerpc_samr_LookupNames(p, mem_ctx, &r1); + if (!NT_STATUS_IS_OK(status)) { + printf("LookupNames failed - %s\n", nt_errstr(status)); + return false; + } + + rid = r1.out.rids.ids[0]; + + r2.in.domain_handle = domain_handle; + r2.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + r2.in.rid = rid; + r2.out.group_handle = &group_handle; + + printf("opening group account\n"); + + status = dcerpc_samr_OpenGroup(p, mem_ctx, &r2); + if (!NT_STATUS_IS_OK(status)) { + printf("OpenGroup failed - %s\n", nt_errstr(status)); + return false; + } + + r3.in.group_handle = &group_handle; + r3.out.group_handle = &group_handle; + + printf("deleting group account\n"); + + status = dcerpc_samr_DeleteDomainGroup(p, mem_ctx, &r3); + if (!NT_STATUS_IS_OK(status)) { + printf("DeleteGroup failed - %s\n", nt_errstr(status)); + return false; + } + + return true; +} + + +bool test_group_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, const char *name, + uint32_t *rid) +{ + NTSTATUS status; + struct lsa_String groupname; + struct samr_CreateDomainGroup r; + struct policy_handle group_handle; + + groupname.string = name; + + r.in.domain_handle = handle; + r.in.name = &groupname; + r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + r.out.group_handle = &group_handle; + r.out.rid = rid; + + printf("creating group account %s\n", name); + + status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("CreateGroup failed - %s\n", nt_errstr(status)); + + if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { + printf("Group (%s) already exists - attempting to delete and recreate account again\n", name); + if (!test_group_cleanup(p, mem_ctx, handle, name)) { + return false; + } + + printf("creating group account\n"); + + status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r); + if (!NT_STATUS_IS_OK(status)) { + printf("CreateGroup failed - %s\n", nt_errstr(status)); + return false; + } + return true; + } + return false; + } + + return true; +} + + +void msg_handler(struct monitor_msg *m) +{ + struct msg_rpc_open_user *msg_open; + struct msg_rpc_query_user *msg_query; + struct msg_rpc_close_user *msg_close; + struct msg_rpc_create_user *msg_create; + + switch (m->type) { + case mon_SamrOpenUser: + msg_open = (struct msg_rpc_open_user*)m->data; + printf("monitor_msg: user opened (rid=%d, access_mask=0x%08x)\n", + msg_open->rid, msg_open->access_mask); + break; + case mon_SamrQueryUser: + msg_query = (struct msg_rpc_query_user*)m->data; + printf("monitor_msg: user queried (level=%d)\n", msg_query->level); + break; + case mon_SamrCloseUser: + msg_close = (struct msg_rpc_close_user*)m->data; + printf("monitor_msg: user closed (rid=%d)\n", msg_close->rid); + break; + case mon_SamrCreateUser: + msg_create = (struct msg_rpc_create_user*)m->data; + printf("monitor_msg: user created (rid=%d)\n", msg_create->rid); + break; + } +} diff --git a/source4/torture/libnet/utils.h b/source4/torture/libnet/utils.h new file mode 100644 index 0000000000..ff94ec49e9 --- /dev/null +++ b/source4/torture/libnet/utils.h @@ -0,0 +1,42 @@ +/* + Unix SMB/CIFS implementation. + Test suite for libnet calls. + + Copyright (C) Rafal Szczesniak 2007 + + 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/>. +*/ + + +bool test_opendomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, struct lsa_String *domname, + struct dom_sid2 *sid); + +bool test_user_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, const char *name, + uint32_t *rid); + +bool test_user_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *domain_handle, + const char *name); + +bool test_group_create(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *handle, const char *name, + uint32_t *rid); + +bool test_group_cleanup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, + struct policy_handle *domain_handle, + const char *name); + +void msg_handler(struct monitor_msg *m); diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk index 1364028ab7..e3ea9e44ef 100644 --- a/source4/torture/local/config.mk +++ b/source4/torture/local/config.mk @@ -28,6 +28,7 @@ OBJ_FILES = \ ../../lib/registry/tests/registry.o \ resolve.o \ ../../lib/util/tests/strlist.o \ + ../../lib/util/tests/str.o \ ../../lib/util/tests/file.o \ ../../lib/util/tests/genrand.o \ ../../lib/compression/testsuite.o \ diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c index 2a9eb49d01..3445812365 100644 --- a/source4/torture/local/dbspeed.c +++ b/source4/torture/local/dbspeed.c @@ -26,10 +26,12 @@ #include "lib/ldb/include/ldb_errors.h" #include "lib/db_wrap.h" #include "torture/torture.h" +#include "param/param.h" float tdb_speed; -static BOOL tdb_add_record(struct tdb_wrap *tdbw, const char *fmt1, const char *fmt2, int i) +static bool tdb_add_record(struct tdb_wrap *tdbw, const char *fmt1, + const char *fmt2, int i) { TDB_DATA key, data; int ret; @@ -48,7 +50,7 @@ static BOOL tdb_add_record(struct tdb_wrap *tdbw, const char *fmt1, const char * /* test tdb speed */ -static BOOL test_tdb_speed(struct torture_context *torture, const void *_data) +static bool test_tdb_speed(struct torture_context *torture, const void *_data) { struct timeval tv; struct tdb_wrap *tdbw; @@ -118,32 +120,32 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data) unlink("test.tdb"); talloc_free(tmp_ctx); - return True; + return true; failed: unlink("test.tdb"); talloc_free(tmp_ctx); - return False; + return false; } -static BOOL ldb_add_record(struct ldb_context *ldb, unsigned rid) +static bool ldb_add_record(struct ldb_context *ldb, unsigned rid) { struct ldb_message *msg; int ret; msg = ldb_msg_new(ldb); if (msg == NULL) { - return False; + return false; } msg->dn = ldb_dn_new_fmt(msg, ldb, "SID=S-1-5-21-53173311-3623041448-2049097239-%u", rid); if (msg->dn == NULL) { - return False; + return false; } if (ldb_msg_add_fmt(msg, "UID", "%u", rid) != 0) { - return False; + return false; } ret = ldb_add(ldb, msg); @@ -157,7 +159,7 @@ static BOOL ldb_add_record(struct ldb_context *ldb, unsigned rid) /* test ldb speed */ -static BOOL test_ldb_speed(struct torture_context *torture, const void *_data) +static bool test_ldb_speed(struct torture_context *torture, const void *_data) { struct timeval tv; struct ldb_context *ldb; @@ -173,7 +175,7 @@ static BOOL test_ldb_speed(struct torture_context *torture, const void *_data) torture_comment(torture, "Testing ldb speed for sidmap\n"); - ldb = ldb_wrap_connect(tmp_ctx, "tdb://test.ldb", + ldb = ldb_wrap_connect(tmp_ctx, global_loadparm, "tdb://test.ldb", NULL, NULL, LDB_FLG_NOSYNC, NULL); if (!ldb) { unlink("./test.ldb"); @@ -239,12 +241,12 @@ static BOOL test_ldb_speed(struct torture_context *torture, const void *_data) unlink("./test.ldb"); talloc_free(tmp_ctx); - return True; + return true; failed: unlink("./test.ldb"); talloc_free(tmp_ctx); - return False; + return false; } struct torture_suite *torture_local_dbspeed(TALLOC_CTX *mem_ctx) diff --git a/source4/torture/local/event.c b/source4/torture/local/event.c index e2c7de1c72..46acf5938e 100644 --- a/source4/torture/local/event.c +++ b/source4/torture/local/event.c @@ -29,7 +29,7 @@ static int fde_count; static void fde_handler(struct event_context *ev_ctx, struct fd_event *f, uint16_t flags, void *private) { - int *fd = private; + int *fd = (int *)private; char c; #ifdef SA_SIGINFO kill(getpid(), SIGUSR1); @@ -43,14 +43,14 @@ static void fde_handler(struct event_context *ev_ctx, struct fd_event *f, static void finished_handler(struct event_context *ev_ctx, struct timed_event *te, struct timeval tval, void *private) { - int *finished = private; + int *finished = (int *)private; (*finished) = 1; } static void count_handler(struct event_context *ev_ctx, struct signal_event *te, int signum, int count, void *info, void *private) { - int *countp = private; + int *countp = (int *)private; (*countp) += count; } diff --git a/source4/torture/local/iconv.c b/source4/torture/local/iconv.c index c543aa7c8f..259769d60f 100644 --- a/source4/torture/local/iconv.c +++ b/source4/torture/local/iconv.c @@ -25,6 +25,7 @@ #include "system/iconv.h" #include "system/time.h" #include "libcli/raw/libcliraw.h" +#include "param/param.h" #include "torture/util.h" #if HAVE_NATIVE_ICONV @@ -33,7 +34,7 @@ static bool iconv_untestable(struct torture_context *tctx) { iconv_t cd; - if (!lp_parm_bool(-1, "iconv", "native", true)) + if (!lp_parm_bool(global_loadparm, NULL, "iconv", "native", true)) torture_skip(tctx, "system iconv disabled - skipping test"); cd = iconv_open("UTF-16LE", "UCS-4LE"); @@ -313,10 +314,10 @@ static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint) static bool test_next_codepoint(struct torture_context *tctx) { + unsigned int codepoint; if (iconv_untestable(tctx)) return true; - unsigned int codepoint; for (codepoint=0;codepoint<(1<<20);codepoint++) { if (!test_codepoint(tctx, codepoint)) return false; @@ -339,7 +340,7 @@ static bool test_first_1m(struct torture_context *tctx) } if (codepoint % 1000 == 0) { - if (torture_setting_bool(tctx, "progress", True)) { + if (torture_setting_bool(tctx, "progress", true)) { torture_comment(tctx, "codepoint=%u \r", codepoint); fflush(stdout); } @@ -402,13 +403,13 @@ struct torture_suite *torture_local_iconv(TALLOC_CTX *mem_ctx) struct torture_suite *suite = torture_suite_create(mem_ctx, "ICONV"); torture_suite_add_simple_test(suite, "next_codepoint()", - test_next_codepoint); + test_next_codepoint); torture_suite_add_simple_test(suite, "first 1M codepoints", - test_first_1m); + test_first_1m); torture_suite_add_simple_test(suite, "5M random UTF-16LE sequences", - test_random_5m); + test_random_5m); return suite; } diff --git a/source4/torture/local/irpc.c b/source4/torture/local/irpc.c index fa6e3e7ade..aae6b4882e 100644 --- a/source4/torture/local/irpc.c +++ b/source4/torture/local/irpc.c @@ -25,10 +25,11 @@ #include "librpc/gen_ndr/ndr_echo.h" #include "torture/torture.h" #include "cluster/cluster.h" +#include "param/param.h" const uint32_t MSG_ID1 = 1, MSG_ID2 = 2; -static BOOL test_debug; +static bool test_debug; struct irpc_test_data { @@ -71,7 +72,7 @@ static void deferred_echodata(struct event_context *ev, struct timed_event *te, */ static NTSTATUS irpc_EchoData(struct irpc_message *irpc, struct echo_EchoData *r) { - irpc->defer_reply = True; + irpc->defer_reply = true; event_add_timed(irpc->ev, irpc, timeval_zero(), deferred_echodata, irpc); return NT_STATUS_OK; } @@ -85,16 +86,16 @@ static bool test_addone(struct torture_context *test, const void *_data, { struct echo_AddOne r; NTSTATUS status; - const struct irpc_test_data *data = _data; + const struct irpc_test_data *data = (const struct irpc_test_data *)_data; uint32_t value = (uint32_t)_value; /* make the call */ r.in.in_data = value; - test_debug = True; + test_debug = true; status = IRPC_CALL(data->msg_ctx1, cluster_id(MSG_ID2), rpcecho, ECHO_ADDONE, &r, test); - test_debug = False; + test_debug = false; torture_assert_ntstatus_ok(test, status, "AddOne failed"); /* check the answer */ @@ -114,7 +115,7 @@ static bool test_echodata(struct torture_context *tctx, { struct echo_EchoData r; NTSTATUS status; - const struct irpc_test_data *data = tcase_data; + const struct irpc_test_data *data = (const struct irpc_test_data *)tcase_data; TALLOC_CTX *mem_ctx = tctx; /* make the call */ @@ -143,7 +144,7 @@ static bool test_echodata(struct torture_context *tctx, static void irpc_callback(struct irpc_request *irpc) { - struct echo_AddOne *r = irpc->r; + struct echo_AddOne *r = (struct echo_AddOne *)irpc->r; int *pong_count = (int *)irpc->async.private; NTSTATUS status = irpc_call_recv(irpc); if (!NT_STATUS_IS_OK(status)) { @@ -165,7 +166,7 @@ static bool test_speed(struct torture_context *tctx, { int ping_count = 0; int pong_count = 0; - const struct irpc_test_data *data = tcase_data; + const struct irpc_test_data *data = (const struct irpc_test_data *)tcase_data; struct timeval tv; struct echo_AddOne r; TALLOC_CTX *mem_ctx = tctx; @@ -208,22 +209,24 @@ static bool test_speed(struct torture_context *tctx, } -static BOOL irpc_setup(struct torture_context *tctx, void **_data) +static bool irpc_setup(struct torture_context *tctx, void **_data) { struct irpc_test_data *data; *_data = data = talloc(tctx, struct irpc_test_data); - lp_set_cmdline("lock dir", "lockdir.tmp"); + lp_set_cmdline(global_loadparm, "pid directory", "piddir.tmp"); data->ev = tctx->ev; torture_assert(tctx, data->msg_ctx1 = messaging_init(tctx, + lp_messaging_path(tctx, global_loadparm), cluster_id(MSG_ID1), data->ev), "Failed to init first messaging context"); torture_assert(tctx, data->msg_ctx2 = messaging_init(tctx, + lp_messaging_path(tctx, global_loadparm), cluster_id(MSG_ID2), data->ev), "Failed to init second messaging context"); @@ -234,7 +237,7 @@ static BOOL irpc_setup(struct torture_context *tctx, void **_data) IRPC_REGISTER(data->msg_ctx1, rpcecho, ECHO_ECHODATA, irpc_EchoData, NULL); IRPC_REGISTER(data->msg_ctx2, rpcecho, ECHO_ECHODATA, irpc_EchoData, NULL); - return True; + return true; } struct torture_suite *torture_local_irpc(TALLOC_CTX *mem_ctx) diff --git a/source4/torture/local/local.c b/source4/torture/local/local.c index 90c3c0d3d9..a52f5d2f7d 100644 --- a/source4/torture/local/local.c +++ b/source4/torture/local/local.c @@ -33,6 +33,7 @@ torture_local_irpc, torture_local_util_strlist, torture_local_util_file, + torture_local_util_str, torture_local_idtree, torture_local_genrand, torture_local_iconv, diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c index 724e2a54c7..bf2b83a0e4 100644 --- a/source4/torture/local/messaging.c +++ b/source4/torture/local/messaging.c @@ -24,6 +24,7 @@ #include "lib/messaging/irpc.h" #include "torture/torture.h" #include "cluster/cluster.h" +#include "param/param.h" static uint32_t msg_pong; @@ -67,20 +68,25 @@ static bool test_ping_speed(struct torture_context *tctx) uint32_t msg_ping, msg_exit; TALLOC_CTX *mem_ctx = tctx; - lp_set_cmdline("pid directory", "piddir.tmp"); + lp_set_cmdline(global_loadparm, "pid directory", "piddir.tmp"); ev = tctx->ev; - msg_server_ctx = messaging_init(mem_ctx, cluster_id(1), ev); + msg_server_ctx = messaging_init(mem_ctx, + lp_messaging_path(tctx, global_loadparm), + cluster_id(1), ev); torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context"); messaging_register_tmp(msg_server_ctx, NULL, ping_message, &msg_ping); messaging_register_tmp(msg_server_ctx, mem_ctx, exit_message, &msg_exit); - msg_client_ctx = messaging_init(mem_ctx, cluster_id(2), ev); + msg_client_ctx = messaging_init(mem_ctx, + lp_messaging_path(mem_ctx, global_loadparm), + cluster_id(2), ev); - torture_assert(tctx, msg_client_ctx != NULL, "msg_client_ctx messaging_init() failed"); + torture_assert(tctx, msg_client_ctx != NULL, + "msg_client_ctx messaging_init() failed"); messaging_register_tmp(msg_client_ctx, &pong_count, pong_message, &msg_pong); diff --git a/source4/torture/local/sddl.c b/source4/torture/local/sddl.c index ac10627783..3e6382309e 100644 --- a/source4/torture/local/sddl.c +++ b/source4/torture/local/sddl.c @@ -33,7 +33,7 @@ static bool test_sddl(struct torture_context *tctx, { struct security_descriptor *sd, *sd2; struct dom_sid *domain; - const char *sddl = test_data; + const char *sddl = (const char *)test_data; const char *sddl2; TALLOC_CTX *mem_ctx = tctx; diff --git a/source4/torture/local/share.c b/source4/torture/local/share.c index 528f34f861..de93e3c591 100644 --- a/source4/torture/local/share.c +++ b/source4/torture/local/share.c @@ -27,7 +27,7 @@ static bool test_list_empty(struct torture_context *tctx, const void *tcase_data, const void *test_data) { - struct share_context *ctx = discard_const(tcase_data); + struct share_context *ctx = (struct share_context *)discard_const(tcase_data); int count; const char **names; @@ -41,7 +41,7 @@ static bool test_create(struct torture_context *tctx, const void *tcase_data, const void *test_data) { - struct share_context *ctx = discard_const(tcase_data); + struct share_context *ctx = (struct share_context *)discard_const(tcase_data); int count; const char **names; int i; @@ -79,7 +79,7 @@ static bool test_create_invalid(struct torture_context *tctx, const void *tcase_data, const void *test_data) { - struct share_context *ctx = discard_const(tcase_data); + struct share_context *ctx = (struct share_context *)discard_const(tcase_data); NTSTATUS status; status = share_create(ctx, "bla", NULL, 0); @@ -102,7 +102,7 @@ static bool test_share_remove_invalid(struct torture_context *tctx, const void *tcase_data, const void *test_data) { - struct share_context *ctx = discard_const(tcase_data); + struct share_context *ctx = (struct share_context *)discard_const(tcase_data); NTSTATUS status; status = share_remove(ctx, "nonexistant"); @@ -121,7 +121,7 @@ static bool test_share_remove(struct torture_context *tctx, const void *tcase_data, const void *test_data) { - struct share_context *ctx = discard_const(tcase_data); + struct share_context *ctx = (struct share_context *)discard_const(tcase_data); struct share_info inf[] = { { SHARE_INFO_STRING, SHARE_TYPE, discard_const_p(void *, "IPC$") }, { SHARE_INFO_STRING, SHARE_PATH, discard_const_p(void *, "/tmp/bla") } @@ -144,7 +144,7 @@ static bool test_double_create(struct torture_context *tctx, const void *tcase_data, const void *test_data) { - struct share_context *ctx = discard_const(tcase_data); + struct share_context *ctx = (struct share_context *)discard_const(tcase_data); struct share_info inf[] = { { SHARE_INFO_STRING, SHARE_TYPE, discard_const_p(void *, "IPC$") }, { SHARE_INFO_STRING, SHARE_PATH, discard_const_p(void *, "/tmp/bla") } @@ -175,17 +175,17 @@ static void tcase_add_share_tests(struct torture_tcase *tcase) torture_tcase_add_test(tcase, "share_double_create", test_double_create, NULL); } -static BOOL setup_ldb(struct torture_context *tctx, void **data) +static bool setup_ldb(struct torture_context *tctx, void **data) { return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "ldb", (struct share_context **)data)); } -static BOOL setup_classic(struct torture_context *tctx, void **data) +static bool setup_classic(struct torture_context *tctx, void **data) { return NT_STATUS_IS_OK(share_get_context_by_name(tctx, "classic", (struct share_context **)data)); } -static BOOL teardown(struct torture_context *tctx, void *data) +static bool teardown(struct torture_context *tctx, void *data) { talloc_free(data); return true; diff --git a/source4/torture/locktest.c b/source4/torture/locktest.c index ba0ba344d9..24b9606961 100644 --- a/source4/torture/locktest.c +++ b/source4/torture/locktest.c @@ -24,17 +24,19 @@ #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" #include "libcli/libcli.h" +#include "param/param.h" +#include "dynconfig.h" static int numops = 1000; -static BOOL showall; -static BOOL analyze; -static BOOL hide_unlock_fails; -static BOOL use_oplocks; +static bool showall; +static bool analyze; +static bool hide_unlock_fails; +static bool use_oplocks; static uint_t lock_range = 100; static uint_t lock_base = 0; static uint_t min_length = 0; -static BOOL exact_error_codes; -static BOOL zero_zero; +static bool exact_error_codes; +static bool zero_zero; #define FILENAME "\\locktest.dat" @@ -122,7 +124,7 @@ static struct smbcli_state *connect_one(char *share, int snum, int conn) char **unc_list = NULL; int num_unc_names; const char *p; - p = lp_parm_string(-1, "torture", "unclist"); + p = lp_parm_string(global_loadparm, NULL, "torture", "unclist"); if (p) { char *h, *s; unc_list = file_lines_load(p, &num_unc_names, NULL); @@ -201,7 +203,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], uint64_t len = rec->len; enum brl_type op = rec->lock_type; int server; - BOOL ret[NSERVERS]; + bool ret[NSERVERS]; NTSTATUS status[NSERVERS]; switch (rec->lock_op) { @@ -251,7 +253,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], op==READ_LOCK?"READ_LOCK":"WRITE_LOCK", nt_errstr(status[0]), nt_errstr(status[1])); } - if (!NT_STATUS_EQUAL(status[0],status[1])) return False; + if (!NT_STATUS_EQUAL(status[0],status[1])) return false; break; case OP_UNLOCK: @@ -293,7 +295,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], nt_errstr(status[0]), nt_errstr(status[1])); } if (!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1])) - return False; + return false; break; case OP_REOPEN: @@ -308,7 +310,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], DENY_NONE); if (fnum[server][conn][f] == -1) { printf("failed to reopen on share%d\n", server); - return False; + return false; } } if (showall) { @@ -318,7 +320,7 @@ static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], break; } - return True; + return true; } static void close_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], @@ -425,7 +427,7 @@ static void test_locks(char *share[NSERVERS]) } else { recorded[n].lock_op = OP_REOPEN; } - recorded[n].needed = True; + recorded[n].needed = true; if (!zero_zero && recorded[n].start==0 && recorded[n].len==0) { recorded[n].len = 1; } @@ -454,7 +456,7 @@ static void test_locks(char *share[NSERVERS]) int m, j; printf("excluding %d-%d\n", i, i+skip-1); for (j=i;j<i+skip;j++) { - recorded[j].needed = False; + recorded[j].needed = false; } close_files(cli, fnum); @@ -463,7 +465,7 @@ static void test_locks(char *share[NSERVERS]) m = retest(cli, fnum, n); if (m == n) { for (j=i;j<i+skip;j++) { - recorded[j].needed = True; + recorded[j].needed = true; } } else { if (i+(skip-1) < m) { @@ -487,7 +489,7 @@ static void test_locks(char *share[NSERVERS]) close_files(cli, fnum); reconnect(cli, fnum, share); open_files(cli, fnum); - showall = True; + showall = true; n1 = retest(cli, fnum, n); if (n1 != n-1) { printf("ERROR - inconsistent result (%u %u)\n", n1, n); @@ -559,7 +561,7 @@ static void usage(void) argc -= NSERVERS; argv += NSERVERS; - lp_load(); + lp_load(dyn_CONFIGFILE); servers[0] = cli_credentials_init(talloc_autofree_context()); servers[1] = cli_credentials_init(talloc_autofree_context()); @@ -592,31 +594,31 @@ static void usage(void) seed = atoi(optarg); break; case 'u': - hide_unlock_fails = True; + hide_unlock_fails = true; break; case 'o': numops = atoi(optarg); break; case 'O': - use_oplocks = True; + use_oplocks = true; break; case 'a': - showall = True; + showall = true; break; case 'A': - analyze = True; + analyze = true; break; case 'Z': - zero_zero = True; + zero_zero = true; break; case 'E': - exact_error_codes = True; + exact_error_codes = true; break; case 'l': - lp_set_cmdline("torture:unclist", optarg); + lp_set_cmdline(global_loadparm, "torture:unclist", optarg); break; case 'W': - lp_set_cmdline("workgroup", optarg); + lp_set_cmdline(global_loadparm, "workgroup", optarg); break; case 'h': usage(); diff --git a/source4/torture/locktest2.c b/source4/torture/locktest2.c index 9d4f0260b1..55edd4aa17 100644 --- a/source4/torture/locktest2.c +++ b/source4/torture/locktest2.c @@ -24,10 +24,10 @@ static fstring password; static fstring username; static int got_pass; static int numops = 1000; -static BOOL showall; -static BOOL analyze; -static BOOL hide_unlock_fails; -static BOOL use_oplocks; +static bool showall; +static bool analyze; +static bool hide_unlock_fails; +static bool use_oplocks; #define FILENAME "\\locktest.dat" #define LOCKRANGE 100 @@ -77,7 +77,7 @@ static int try_open(struct smbcli_state *c, char *nfs, int fstype, const char *f return -1; } -static BOOL try_close(struct smbcli_state *c, int fstype, int fd) +static bool try_close(struct smbcli_state *c, int fstype, int fd) { switch (fstype) { case FSTYPE_SMB: @@ -87,10 +87,10 @@ static BOOL try_close(struct smbcli_state *c, int fstype, int fd) return close(fd) == 0; } - return False; + return false; } -static BOOL try_lock(struct smbcli_state *c, int fstype, +static bool try_lock(struct smbcli_state *c, int fstype, int fd, uint_t start, uint_t len, enum brl_type op) { @@ -109,10 +109,10 @@ static BOOL try_lock(struct smbcli_state *c, int fstype, return fcntl(fd,F_SETLK,&lock) == 0; } - return False; + return false; } -static BOOL try_unlock(struct smbcli_state *c, int fstype, +static bool try_unlock(struct smbcli_state *c, int fstype, int fd, uint_t start, uint_t len) { struct flock lock; @@ -130,7 +130,7 @@ static BOOL try_unlock(struct smbcli_state *c, int fstype, return fcntl(fd,F_SETLK,&lock) == 0; } - return False; + return false; } /***************************************************** @@ -207,7 +207,7 @@ static void reconnect(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], -static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], +static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], char *nfs[NSERVERS], int fnum[NSERVERS][NUMFSTYPES][NCONNECTIONS][NFILES], struct record *rec) @@ -221,7 +221,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], uint_t r2 = rec->r2; enum brl_type op; int server; - BOOL ret[NSERVERS]; + bool ret[NSERVERS]; if (r1 < READ_PCT) { op = READ_LOCK; @@ -243,7 +243,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], op==READ_LOCK?"READ_LOCK":"WRITE_LOCK", ret[0], ret[1]); } - if (ret[0] != ret[1]) return False; + if (ret[0] != ret[1]) return false; } else if (r2 < LOCK_PCT+UNLOCK_PCT) { /* unset a lock */ for (server=0;server<NSERVERS;server++) { @@ -257,7 +257,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], start, start+len-1, len, ret[0], ret[1]); } - if (!hide_unlock_fails && ret[0] != ret[1]) return False; + if (!hide_unlock_fails && ret[0] != ret[1]) return false; } else { /* reopen the file */ for (server=0;server<NSERVERS;server++) { @@ -266,7 +266,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], O_RDWR|O_CREAT); if (fnum[server][fstype][conn][f] == -1) { printf("failed to reopen on share1\n"); - return False; + return false; } } if (showall) { @@ -274,7 +274,7 @@ static BOOL test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], conn, fstype, f); } } - return True; + return true; } static void close_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], @@ -369,7 +369,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath recorded[n].len *= RANGE_MULTIPLE; recorded[n].r1 = random() % 100; recorded[n].r2 = random() % 100; - recorded[n].needed = True; + recorded[n].needed = true; } reconnect(cli, nfs, fnum, share1, share2); @@ -388,14 +388,14 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath for (i=0;i<n-1;i++) { int m; - recorded[i].needed = False; + recorded[i].needed = false; close_files(cli, nfs, fnum); open_files(cli, nfs, fnum); m = retest(cli, nfs, fnum, n); if (m == n) { - recorded[i].needed = True; + recorded[i].needed = true; } else { if (i < m) { memmove(&recorded[i], &recorded[i+1], @@ -412,7 +412,7 @@ static void test_locks(char *share1, char *share2, char *nfspath1, char *nfspath close_files(cli, nfs, fnum); reconnect(cli, nfs, fnum, share1, share2); open_files(cli, nfs, fnum); - showall = True; + showall = true; n1 = retest(cli, nfs, fnum, n); if (n1 != n-1) { printf("ERROR - inconsistent result (%u %u)\n", n1, n); @@ -483,7 +483,7 @@ static void usage(void) argc -= 4; argv += 4; - lp_load(); + lp_load(dyn_CONFIGFILE); if (getenv("USER")) { fstrcpy(username,getenv("USER")); @@ -506,19 +506,19 @@ static void usage(void) seed = atoi(optarg); break; case 'u': - hide_unlock_fails = True; + hide_unlock_fails = true; break; case 'o': numops = atoi(optarg); break; case 'O': - use_oplocks = True; + use_oplocks = true; break; case 'a': - showall = True; + showall = true; break; case 'A': - analyze = True; + analyze = true; break; case 'h': usage(); diff --git a/source4/torture/masktest.c b/source4/torture/masktest.c index 3eac50cbca..fec7657afe 100644 --- a/source4/torture/masktest.c +++ b/source4/torture/masktest.c @@ -26,10 +26,12 @@ #include "pstring.h" #include "auth/credentials/credentials.h" #include "auth/gensec/gensec.h" +#include "param/param.h" +#include "dynconfig.h" static struct cli_credentials *credentials; -static BOOL showall = False; -static BOOL old_list = False; +static bool showall = false; +static bool old_list = false; static const char *maskchars = "<>\"?*abc."; static const char *filechars = "abcdefghijklm."; static int verbose; @@ -37,12 +39,12 @@ static int die_on_error; static int NumLoops = 0; static int max_length = 20; -static BOOL reg_match_one(struct smbcli_state *cli, const char *pattern, const char *file) +static bool reg_match_one(struct smbcli_state *cli, const char *pattern, const char *file) { /* oh what a weird world this is */ - if (old_list && strcmp(pattern, "*.*") == 0) return True; + if (old_list && strcmp(pattern, "*.*") == 0) return true; - if (ISDOT(pattern)) return False; + if (ISDOT(pattern)) return false; if (ISDOTDOT(file)) file = "."; @@ -98,7 +100,7 @@ static struct { pstring long_name; pstring short_name; } last_hit; -static BOOL f_info_hit; +static bool f_info_hit; static void listfn(struct clilist_file_info *f, const char *s, void *state) { @@ -111,7 +113,7 @@ static void listfn(struct clilist_file_info *f, const char *s, void *state) } pstrcpy(last_hit.long_name, f->name); pstrcpy(last_hit.short_name, f->short_name); - f_info_hit = True; + f_info_hit = true; } static void get_real_name(struct smbcli_state *cli, @@ -124,7 +126,7 @@ static void get_real_name(struct smbcli_state *cli, mask = "\\masktest\\*"; } - f_info_hit = False; + f_info_hit = false; smbcli_list_new(cli->tree, mask, FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_DIRECTORY, @@ -284,7 +286,7 @@ static void usage(void) setup_logging("masktest", DEBUG_STDOUT); - lp_set_cmdline("log level", "0"); + lp_set_cmdline(global_loadparm, "log level", "0"); if (argc < 2 || argv[1][0] == '-') { usage(); @@ -300,7 +302,7 @@ static void usage(void) argc -= 1; argv += 1; - lp_load(); + lp_load(dyn_CONFIGFILE); credentials = cli_credentials_init(talloc_autofree_context()); cli_credentials_guess(credentials); @@ -324,7 +326,7 @@ static void usage(void) verbose++; break; case 'M': - lp_set_cmdline("max protocol", optarg); + lp_set_cmdline(global_loadparm, "max protocol", optarg); break; case 'U': cli_credentials_parse_string(credentials, optarg, CRED_SPECIFIED); @@ -348,7 +350,7 @@ static void usage(void) showall = 1; break; case 'o': - old_list = True; + old_list = true; break; default: printf("Unknown option %c (%d)\n", (char)opt, opt); diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c index d01c5a7ecd..ddedd102f9 100644 --- a/source4/torture/nbench/nbench.c +++ b/source4/torture/nbench/nbench.c @@ -56,14 +56,14 @@ static void do_reconnect(struct smbcli_state **cli, int client) } /* run a test that simulates an approximate netbench client load */ -static BOOL run_netbench(struct torture_context *tctx, struct smbcli_state *cli, int client) +static bool run_netbench(struct torture_context *tctx, struct smbcli_state *cli, int client) { int torture_nprocs = torture_setting_int(tctx, "nprocs", 4); int i; pstring line; char *cname; FILE *f; - BOOL correct = True; + bool correct = true; double target_rate = torture_setting_double(tctx, "targetrate", 0); int n; @@ -85,7 +85,7 @@ static BOOL run_netbench(struct torture_context *tctx, struct smbcli_state *cli, if (!f) { perror(loadfile); - return False; + return false; } again: @@ -212,7 +212,7 @@ done: smbcli_deltree(cli->tree, "\\clients"); } if (!torture_close_connection(cli)) { - correct = False; + correct = false; } return correct; @@ -220,14 +220,14 @@ done: /* run a test that simulates an approximate netbench client load */ -BOOL torture_nbench(struct torture_context *torture) +bool torture_nbench(struct torture_context *torture) { - BOOL correct = True; + bool correct = true; int torture_nprocs = torture_setting_int(torture, "nprocs", 4); struct smbcli_state *cli; const char *p; - read_only = torture_setting_bool(torture, "readonly", False); + read_only = torture_setting_bool(torture, "readonly", false); nb_max_retries = torture_setting_int(torture, "nretries", 1); @@ -245,11 +245,11 @@ BOOL torture_nbench(struct torture_context *torture) if (torture_nprocs > 1) { if (!torture_open_connection(&cli, 0)) { - return False; + return false; } if (!read_only && !torture_setup_dir(cli, "\\clients")) { - return False; + return false; } } diff --git a/source4/torture/nbench/nbio.c b/source4/torture/nbench/nbio.c index 9624a7b14f..5de903ff78 100644 --- a/source4/torture/nbench/nbio.c +++ b/source4/torture/nbench/nbio.c @@ -36,7 +36,7 @@ extern int nbench_line_count; static int nbio_id = -1; static int nprocs; -static BOOL bypass_io; +static bool bypass_io; static struct timeval tv_start, tv_end; static int warmup, timelimit; static int in_cleanup; @@ -117,13 +117,13 @@ static bool nb_reestablish_locks(struct ftable *f) if (!nb_do_lockx(true, f->handle, linfo->offset, linfo->size, NT_STATUS_OK)) { printf("nb_reestablish_locks: failed to get lock for file %s at %lu\n", f->cp.fname, (unsigned long) linfo->offset); - return False; + return false; } linfo = linfo->next; } - return True; + return true; } static bool nb_reopen_all_files(void) @@ -140,21 +140,21 @@ static bool nb_reopen_all_files(void) f->cp.create_disposition, f->cp.handle, NT_STATUS_OK, - True)) + true)) { printf("-- nb_reopen_all_files: failed to open file %s\n", f->cp.fname); - return False; + return false; } if (!nb_reestablish_locks(f)) { printf("--nb_reopen_all_files: failed to reestablish locks\n"); - return False; + return false; } f = f->next; } - return True; + return true; } bool nb_reconnect(struct smbcli_state **cli, int client) @@ -168,17 +168,17 @@ bool nb_reconnect(struct smbcli_state **cli, int client) if (!torture_open_connection(cli, client)) { printf("nb_reconnect: failed to connect\n"); *cli = NULL; - return False; + return false; } nb_setup(*cli, client); if (!nb_reopen_all_files()) { printf("nb_reconnect: failed to reopen files in client %d\n", client); - return False; + return false; } - return True; + return true; } void nbio_target_rate(double rate) @@ -242,7 +242,7 @@ double nbio_latency(void) return max_latency; } -BOOL nb_tick(void) +bool nb_tick(void) { return children[nbio_id].done; } @@ -383,10 +383,10 @@ static struct smbcli_state *c; /* a handler function for oplock break requests */ -static BOOL oplock_handler(struct smbcli_transport *transport, uint16_t tid, +static bool oplock_handler(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private) { - struct smbcli_tree *tree = private; + struct smbcli_tree *tree = (struct smbcli_tree *)private; return smbcli_oplock_ack(tree, fnum, OPLOCK_BREAK_TO_NONE); } @@ -412,7 +412,7 @@ static bool check_status(const char *op, NTSTATUS status, NTSTATUS ret) NT_STATUS_EQUAL(ret, NT_STATUS_CONNECTION_RESET)) && !NT_STATUS_EQUAL (status, ret)) { - return False; + return false; } if (!NT_STATUS_IS_OK(status) && NT_STATUS_IS_OK(ret)) { @@ -432,7 +432,7 @@ static bool check_status(const char *op, NTSTATUS status, NTSTATUS ret) nbench_line_count, nt_errstr(ret), nt_errstr(status)); } - return True; + return true; } @@ -453,7 +453,7 @@ bool nb_unlink(const char *fname, int attr, NTSTATUS status, bool retry) if (!retry) return check_status("Unlink", status, ret); - return True; + return true; } static bool nb_do_createx(struct ftable *f, @@ -515,10 +515,10 @@ static bool nb_do_createx(struct ftable *f, talloc_free(mem_ctx); if (!check_status("NTCreateX", status, ret)) - return False; + return false; if (!NT_STATUS_IS_OK(ret)) - return True; + return true; if (f == NULL) { f = talloc (NULL, struct ftable); @@ -530,14 +530,14 @@ static bool nb_do_createx(struct ftable *f, f->handle = handle; f->fd = io.ntcreatex.out.file.fnum; - return True; + return true; } bool nb_createx(const char *fname, uint_t create_options, uint_t create_disposition, int handle, NTSTATUS status) { - return nb_do_createx(NULL, fname, create_options, create_disposition, handle, status, False); + return nb_do_createx(NULL, fname, create_options, create_disposition, handle, status, false); } bool nb_writex(int handle, off_t offset, int size, int ret_size, NTSTATUS status) @@ -550,7 +550,7 @@ bool nb_writex(int handle, off_t offset, int size, int ret_size, NTSTATUS status i = find_handle(handle, NULL); if (bypass_io) - return True; + return true; buf = malloc(size); memset(buf, 0xab, size); @@ -568,7 +568,7 @@ bool nb_writex(int handle, off_t offset, int size, int ret_size, NTSTATUS status free(buf); if (!check_status("WriteX", status, ret)) - return False; + return false; if (NT_STATUS_IS_OK(ret) && io.writex.out.nwritten != ret_size) { printf("[%d] Warning: WriteX got count %d expected %d\n", @@ -578,7 +578,7 @@ bool nb_writex(int handle, off_t offset, int size, int ret_size, NTSTATUS status children[nbio_id].bytes += ret_size; - return True; + return true; } bool nb_write(int handle, off_t offset, int size, int ret_size, NTSTATUS status) @@ -591,7 +591,7 @@ bool nb_write(int handle, off_t offset, int size, int ret_size, NTSTATUS status) i = find_handle(handle, NULL); if (bypass_io) - return True; + return true; buf = malloc(size); @@ -609,7 +609,7 @@ bool nb_write(int handle, off_t offset, int size, int ret_size, NTSTATUS status) free(buf); if (!check_status("Write", status, ret)) - return False; + return false; if (NT_STATUS_IS_OK(ret) && io.write.out.nwritten != ret_size) { printf("[%d] Warning: Write got count %d expected %d\n", @@ -619,7 +619,7 @@ bool nb_write(int handle, off_t offset, int size, int ret_size, NTSTATUS status) children[nbio_id].bytes += ret_size; - return True; + return true; } static bool nb_do_lockx(bool relock, int handle, off_t offset, int size, NTSTATUS status) @@ -647,7 +647,7 @@ static bool nb_do_lockx(bool relock, int handle, off_t offset, int size, NTSTATU ret = smb_raw_lock(c->tree, &io); if (!check_status("LockX", status, ret)) - return False; + return false; if (f != NULL && !relock) @@ -659,7 +659,7 @@ static bool nb_do_lockx(bool relock, int handle, off_t offset, int size, NTSTATU DLIST_ADD_END(f->locks, linfo, struct lock_info *); } - return True; + return true; } bool nb_lockx(int handle, off_t offset, int size, NTSTATUS status) @@ -692,7 +692,7 @@ bool nb_unlockx(int handle, uint_t offset, int size, NTSTATUS status) ret = smb_raw_lock(c->tree, &io); if (!check_status("UnlockX", status, ret)) - return False; + return false; if (f != NULL) { struct lock_info *linfo; @@ -703,7 +703,7 @@ bool nb_unlockx(int handle, uint_t offset, int size, NTSTATUS status) printf("nb_unlockx: unknown lock (%d)\n", handle); } - return True; + return true; } bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status) @@ -716,7 +716,7 @@ bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status) i = find_handle(handle, NULL); if (bypass_io) - return True; + return true; buf = malloc(size); @@ -726,7 +726,7 @@ bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status) io.readx.in.mincnt = size; io.readx.in.maxcnt = size; io.readx.in.remaining = 0; - io.readx.in.read_for_execute = False; + io.readx.in.read_for_execute = false; io.readx.out.data = buf; ret = smb_raw_read(c->tree, &io); @@ -734,7 +734,7 @@ bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status) free(buf); if (!check_status("ReadX", status, ret)) - return False; + return false; if (NT_STATUS_IS_OK(ret) && io.readx.out.nread != ret_size) { printf("[%d] ERROR: ReadX got count %d expected %d\n", @@ -745,7 +745,7 @@ bool nb_readx(int handle, off_t offset, int size, int ret_size, NTSTATUS status) children[nbio_id].bytes += ret_size; - return True; + return true; } bool nb_close(int handle, NTSTATUS status) @@ -763,7 +763,7 @@ bool nb_close(int handle, NTSTATUS status) ret = smb_raw_close(c->tree, &io); if (!check_status("Close", status, ret)) - return False; + return false; if (NT_STATUS_IS_OK(ret)) { struct ftable *f = find_ftable(handle); @@ -771,7 +771,7 @@ bool nb_close(int handle, NTSTATUS status) talloc_free(f); } - return True; + return true; } bool nb_rmdir(const char *dname, NTSTATUS status, bool retry) @@ -786,7 +786,7 @@ bool nb_rmdir(const char *dname, NTSTATUS status, bool retry) if (!retry) return check_status("Rmdir", status, ret); - return True; + return true; } bool nb_mkdir(const char *dname, NTSTATUS status, bool retry) @@ -799,7 +799,7 @@ bool nb_mkdir(const char *dname, NTSTATUS status, bool retry) /* NOTE! no error checking. Used for base fileset creation */ smb_raw_mkdir(c->tree, &io); - return True; + return true; } bool nb_rename(const char *old, const char *new, NTSTATUS status, bool retry) @@ -817,7 +817,7 @@ bool nb_rename(const char *old, const char *new, NTSTATUS status, bool retry) if (!retry) return check_status("Rename", status, ret); - return True; + return true; } @@ -869,7 +869,7 @@ bool nb_sfileinfo(int fnum, int level, NTSTATUS status) if (level != RAW_SFILEINFO_BASIC_INFORMATION) { printf("[%d] Warning: setfileinfo level %d not handled\n", nbench_line_count, level); - return True; + return true; } ZERO_STRUCT(io); @@ -906,9 +906,9 @@ bool nb_qfsinfo(int level, NTSTATUS status) } /* callback function used for trans2 search */ -static BOOL findfirst_callback(void *private, const union smb_search_data *file) +static bool findfirst_callback(void *private, const union smb_search_data *file) { - return True; + return true; } bool nb_findfirst(const char *mask, int level, int maxcnt, int count, NTSTATUS status) @@ -932,7 +932,7 @@ bool nb_findfirst(const char *mask, int level, int maxcnt, int count, NTSTATUS s talloc_free(mem_ctx); if (!check_status("Search", status, ret)) - return False; + return false; if (NT_STATUS_IS_OK(ret) && io.t2ffirst.out.count != count) { printf("[%d] Warning: got count %d expected %d\n", @@ -940,7 +940,7 @@ bool nb_findfirst(const char *mask, int level, int maxcnt, int count, NTSTATUS s io.t2ffirst.out.count, count); } - return True; + return true; } bool nb_flush(int fnum, NTSTATUS status) @@ -984,7 +984,7 @@ bool nb_deltree(const char *dname, bool retry) smbcli_rmdir(c->tree, dname); - return True; + return true; } diff --git a/source4/torture/nbt/browse.c b/source4/torture/nbt/browse.c index a9aac79469..e609e72055 100644 --- a/source4/torture/nbt/browse.c +++ b/source4/torture/nbt/browse.c @@ -33,7 +33,7 @@ bool torture_nbt_browse(struct torture_context *torture) struct nbt_name name; TALLOC_CTX *mem_ctx = talloc_new(NULL); NTSTATUS status; - BOOL ret = True; + bool ret = true; name.name = lp_workgroup(); name.type = NBT_NAME_BROWSER; @@ -45,7 +45,7 @@ bool torture_nbt_browse(struct torture_context *torture) printf("Failed to resolve %s - %s\n", name.name, nt_errstr(status)); talloc_free(mem_ctx); - return False; + return false; } talloc_free(mem_ctx); diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c index 2effe25ab7..e9cfda4b17 100644 --- a/source4/torture/nbt/dgram.c +++ b/source4/torture/nbt/dgram.c @@ -30,6 +30,7 @@ #include "libcli/resolve/resolve.h" #include "system/network.h" #include "lib/socket/netif.h" +#include "param/param.h" #define TEST_NAME "TORTURE_TEST" @@ -42,7 +43,7 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot, { NTSTATUS status; struct nbt_netlogon_packet netlogon; - int *replies = dgmslot->private; + int *replies = (int *)dgmslot->private; printf("netlogon reply from %s:%d\n", src->addr, src->port); @@ -77,7 +78,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx) const char *address; struct nbt_name name; - name.name = lp_workgroup(); + name.name = lp_workgroup(global_loadparm); name.type = NBT_NAME_LOGON; name.scope = NULL; @@ -90,7 +91,7 @@ static bool nbt_test_netlogon(struct torture_context *tctx) socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, - myaddress, lp_dgram_port()); + myaddress, lp_dgram_port(global_loadparm)); torture_assert(tctx, socket_address != NULL, "Error getting address"); /* try receiving replies on port 138 first, which will only @@ -156,7 +157,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) const char *address; struct nbt_name name; - name.name = lp_workgroup(); + name.name = lp_workgroup(global_loadparm); name.type = NBT_NAME_LOGON; name.scope = NULL; @@ -168,7 +169,7 @@ static bool nbt_test_netlogon2(struct torture_context *tctx) myaddress = talloc_strdup(dgmsock, iface_best_ip(address)); socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, - myaddress, lp_dgram_port()); + myaddress, lp_dgram_port(global_loadparm)); torture_assert(tctx, socket_address != NULL, "Error getting address"); /* try receiving replies on port 138 first, which will only @@ -227,7 +228,7 @@ static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot, { NTSTATUS status; struct nbt_ntlogon_packet ntlogon; - int *replies = dgmslot->private; + int *replies = (int *)dgmslot->private; printf("ntlogon reply from %s:%d\n", src->addr, src->port); @@ -265,7 +266,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) const char *address; struct nbt_name name; - name.name = lp_workgroup(); + name.name = lp_workgroup(global_loadparm); name.type = NBT_NAME_LOGON; name.scope = NULL; @@ -277,7 +278,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) myaddress = talloc_strdup(dgmsock, iface_best_ip(address)); socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, - myaddress, lp_dgram_port()); + myaddress, lp_dgram_port(global_loadparm)); torture_assert(tctx, socket_address != NULL, "Error getting address"); /* try receiving replies on port 138 first, which will only @@ -298,7 +299,7 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) ACB_WSTRUST, &machine_credentials); torture_assert(tctx, join_ctx != NULL, talloc_asprintf(tctx, "Failed to join domain %s as %s\n", - lp_workgroup(), TEST_NAME)); + lp_workgroup(global_loadparm), TEST_NAME)); dom_sid = torture_join_sid(join_ctx); @@ -340,9 +341,9 @@ static bool nbt_test_ntlogon(struct torture_context *tctx) /* test nbt dgram operations */ -struct torture_suite *torture_nbt_dgram(void) +struct torture_suite *torture_nbt_dgram(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "DGRAM"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "DGRAM"); torture_suite_add_simple_test(suite, "netlogon", nbt_test_netlogon); torture_suite_add_simple_test(suite, "netlogon2", nbt_test_netlogon2); diff --git a/source4/torture/nbt/nbt.c b/source4/torture/nbt/nbt.c index 5c941c60c9..2a3678ee75 100644 --- a/source4/torture/nbt/nbt.c +++ b/source4/torture/nbt/nbt.c @@ -29,7 +29,7 @@ bool torture_nbt_get_name(struct torture_context *tctx, const char **address) { make_nbt_name_server(name, strupper_talloc(tctx, - torture_setting_string(tctx, "host", NULL))); + torture_setting_string(tctx, "host", NULL))); /* do an initial name resolution to find its IP */ torture_assert_ntstatus_ok(tctx, @@ -43,18 +43,17 @@ bool torture_nbt_get_name(struct torture_context *tctx, NTSTATUS torture_nbt_init(void) { struct torture_suite *suite = torture_suite_create( - talloc_autofree_context(), - "NBT"); + talloc_autofree_context(), "NBT"); /* nbt tests */ - torture_suite_add_suite(suite, torture_nbt_register()); - torture_suite_add_suite(suite, torture_nbt_wins()); - torture_suite_add_suite(suite, torture_nbt_dgram()); - torture_suite_add_suite(suite, torture_nbt_winsreplication()); - torture_suite_add_suite(suite, torture_bench_nbt()); - torture_suite_add_suite(suite, torture_bench_wins()); + torture_suite_add_suite(suite, torture_nbt_register(suite)); + torture_suite_add_suite(suite, torture_nbt_wins(suite)); + torture_suite_add_suite(suite, torture_nbt_dgram(suite)); + torture_suite_add_suite(suite, torture_nbt_winsreplication(suite)); + torture_suite_add_suite(suite, torture_bench_nbt(suite)); + torture_suite_add_suite(suite, torture_bench_wins(suite)); suite->description = talloc_strdup(suite, - "NetBIOS over TCP/IP and WINS tests"); + "NetBIOS over TCP/IP and WINS tests"); torture_register_suite(suite); diff --git a/source4/torture/nbt/query.c b/source4/torture/nbt/query.c index 5794d840ec..1040335227 100644 --- a/source4/torture/nbt/query.c +++ b/source4/torture/nbt/query.c @@ -61,8 +61,8 @@ static bool bench_namequery(struct torture_context *tctx) io.in.name = name; io.in.dest_addr = address; - io.in.broadcast = False; - io.in.wins_lookup = False; + io.in.broadcast = false; + io.in.wins_lookup = false; io.in.timeout = 1; result = talloc_zero(tctx, struct result_struct); @@ -104,10 +104,9 @@ static bool bench_namequery(struct torture_context *tctx) /* benchmark how fast a server can respond to name queries */ -struct torture_suite *torture_bench_nbt(void) +struct torture_suite *torture_bench_nbt(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), - "BENCH"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "BENCH"); torture_suite_add_simple_test(suite, "namequery", bench_namequery); return suite; diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c index 03cc4e6cee..9ff22c4bb9 100644 --- a/source4/torture/nbt/register.c +++ b/source4/torture/nbt/register.c @@ -68,9 +68,9 @@ static bool nbt_register_own(struct torture_context *tctx) io.in.dest_addr = address; io.in.address = myaddress; io.in.nb_flags = NBT_NODE_B | NBT_NM_ACTIVE; - io.in.register_demand = False; - io.in.broadcast = True; - io.in.multi_homed = False; + io.in.register_demand = false; + io.in.broadcast = true; + io.in.multi_homed = false; io.in.ttl = 1234; io.in.timeout = 3; io.in.retries = 0; @@ -86,7 +86,7 @@ static bool nbt_register_own(struct torture_context *tctx) /* check a register demand */ io.in.address = myaddress; - io.in.register_demand = True; + io.in.register_demand = true; status = nbt_name_register(nbtsock, tctx, &io); @@ -134,7 +134,7 @@ static bool nbt_refresh_own(struct torture_context *tctx) io.in.dest_addr = address; io.in.address = myaddress; io.in.nb_flags = NBT_NODE_B | NBT_NM_ACTIVE; - io.in.broadcast = False; + io.in.broadcast = false; io.in.ttl = 1234; io.in.timeout = 3; io.in.retries = 0; @@ -155,11 +155,11 @@ static bool nbt_refresh_own(struct torture_context *tctx) /* test name registration to a server */ -struct torture_suite *torture_nbt_register(void) +struct torture_suite *torture_nbt_register(TALLOC_CTX *mem_ctx) { struct torture_suite *suite; - suite = torture_suite_create(talloc_autofree_context(), "REGISTER"); + suite = torture_suite_create(mem_ctx, "REGISTER"); torture_suite_add_simple_test(suite, "register_own", nbt_register_own); torture_suite_add_simple_test(suite, "refresh_own", nbt_refresh_own); diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c index 7f3ed8e415..e25c3e78f0 100644 --- a/source4/torture/nbt/wins.c +++ b/source4/torture/nbt/wins.c @@ -77,7 +77,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address release.in.dest_addr = address; release.in.address = myaddress; release.in.nb_flags = nb_flags; - release.in.broadcast = False; + release.in.broadcast = false; release.in.timeout = 3; release.in.retries = 0; @@ -113,8 +113,8 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address torture_comment(tctx, "query the name to make sure its there\n"); query.in.name = *name; query.in.dest_addr = address; - query.in.broadcast = False; - query.in.wins_lookup = True; + query.in.broadcast = false; + query.in.wins_lookup = true; query.in.timeout = 3; query.in.retries = 0; @@ -174,7 +174,7 @@ static bool nbt_test_wins_name(struct torture_context *tctx, const char *address release.in.dest_addr = address; release.in.address = myaddress; release.in.nb_flags = nb_flags; - release.in.broadcast = False; + release.in.broadcast = false; release.in.timeout = 3; release.in.retries = 0; @@ -284,10 +284,9 @@ static bool nbt_test_wins(struct torture_context *tctx) /* test WINS operations */ -struct torture_suite *torture_nbt_wins(void) +struct torture_suite *torture_nbt_wins(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), - "WINS"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "WINS"); torture_suite_add_simple_test(suite, "wins", nbt_test_wins); diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c index f06db648fc..27edd57206 100644 --- a/source4/torture/nbt/winsbench.c +++ b/source4/torture/nbt/winsbench.c @@ -282,11 +282,10 @@ static bool bench_wins(struct torture_context *tctx) benchmark how fast a WINS server can respond to a mixture of registration/refresh/release and name query requests */ -struct torture_suite *torture_bench_wins(void) +struct torture_suite *torture_bench_wins(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create( - talloc_autofree_context(), - "BENCH-WINS"); + struct torture_suite *suite = torture_suite_create(mem_ctx, + "BENCH-WINS"); torture_suite_add_simple_test(suite, "wins", bench_wins); diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c index bc370c8b4e..f0b17b9778 100644 --- a/source4/torture/nbt/winsreplication.c +++ b/source4/torture/nbt/winsreplication.c @@ -30,6 +30,7 @@ #include "librpc/gen_ndr/ndr_nbt.h" #include "torture/torture.h" #include "torture/nbt/proto.h" +#include "param/param.h" #define CHECK_STATUS(tctx, status, correct) \ torture_assert_ntstatus_equal(tctx, status, correct, \ @@ -97,10 +98,6 @@ static bool test_assoc_ctx1(struct torture_context *tctx) struct nbt_name name; const char *address; - if (!torture_setting_bool(tctx, "dangerous", false)) { - torture_skip(tctx, "winsrepl: cross connection assoc_ctx usage disabled - enable dangerous tests to use"); - } - if (!torture_nbt_get_name(tctx, &name, &address)) return false; @@ -224,7 +221,7 @@ static bool test_assoc_ctx2(struct torture_context *tctx) /* display a replication entry */ -static void display_entry(TALLOC_CTX *tctx, struct wrepl_name *name) +static void display_entry(struct torture_context *tctx, struct wrepl_name *name) { int i; @@ -541,8 +538,8 @@ static const struct wrepl_ip addresses_X_3_4[] = { } }; -static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *tctx, - const char *address) +static struct test_wrepl_conflict_conn *test_create_conflict_ctx( + struct torture_context *tctx, const char *address) { struct test_wrepl_conflict_conn *ctx; struct wrepl_associate associate; @@ -632,7 +629,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *tct if (!ctx->nbtsock_srv) return NULL; /* Make a port 137 version of ctx->myaddr */ - nbt_srv_addr = socket_address_from_strings(tctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr->addr, lp_nbt_port()); + nbt_srv_addr = socket_address_from_strings(tctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr->addr, lp_nbt_port(global_loadparm)); if (!nbt_srv_addr) return NULL; /* And if possible, bind to it. This won't work unless we are root or in sockewrapper */ @@ -657,7 +654,8 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *tct /* Make a port 137 version of ctx->myaddr2 */ nbt_srv_addr = socket_address_from_strings(tctx, ctx->nbtsock_srv->sock->backend_name, - ctx->myaddr2->addr, lp_nbt_port()); + ctx->myaddr2->addr, + lp_nbt_port(global_loadparm)); if (!nbt_srv_addr) return NULL; /* And if possible, bind to it. This won't work unless we are root or in sockewrapper */ @@ -9158,7 +9156,7 @@ static bool test_conflict_owned_active_vs_replica(struct torture_context *tctx, if (!ctx->nbtsock_srv) { torture_comment(tctx, "SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n", - lp_nbt_port()); + lp_nbt_port(global_loadparm)); return true; } @@ -9454,7 +9452,8 @@ static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_ { struct nbt_name *name; struct nbt_name_packet *rep_packet; - struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private; + struct test_conflict_owned_active_vs_replica_struct *rec = + (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private; _NBT_ASSERT(req_packet->qdcount, 1); _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS); @@ -9550,7 +9549,8 @@ static void test_conflict_owned_active_vs_replica_handler_release( { struct nbt_name *name; struct nbt_name_packet *rep_packet; - struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private; + struct test_conflict_owned_active_vs_replica_struct *rec = + (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private; _NBT_ASSERT(req_packet->qdcount, 1); _NBT_ASSERT(req_packet->questions[0].question_type, NBT_QTYPE_NETBIOS); @@ -9601,7 +9601,8 @@ static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket struct nbt_name_packet *req_packet, struct socket_address *src) { - struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private; + struct test_conflict_owned_active_vs_replica_struct *rec = + (struct test_conflict_owned_active_vs_replica_struct *)nbtsock->incoming.private; rec->defend.ret = false; @@ -9670,13 +9671,15 @@ static bool torture_nbt_winsreplication_owned(struct torture_context *tctx) /* test simple WINS replication operations */ -struct torture_suite *torture_nbt_winsreplication(void) +struct torture_suite *torture_nbt_winsreplication(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create( - talloc_autofree_context(), - "WINSREPLICATION"); - torture_suite_add_simple_test(suite, "assoc_ctx1", - test_assoc_ctx1); + mem_ctx, "WINSREPLICATION"); + struct torture_tcase *tcase; + + tcase = torture_suite_add_simple_test(suite, "assoc_ctx1", + test_assoc_ctx1); + tcase->tests->dangerous = true; torture_suite_add_simple_test(suite, "assoc_ctx2", test_assoc_ctx2); diff --git a/source4/torture/ndr/lsa.c b/source4/torture/ndr/lsa.c index 768c8db63e..a72a03fa38 100644 --- a/source4/torture/ndr/lsa.c +++ b/source4/torture/ndr/lsa.c @@ -1747,7 +1747,7 @@ static const uint8_t lsarlookupsids3_out_data[] = { }; static bool lsarlookupsids3_out_check(struct torture_context *tctx, - struct lsa_LookupSids3 *r) + struct lsa_LookupSids3 *r) { /* FIXME: Handle */ torture_assert(tctx, r->out.names != NULL, "names ptr"); diff --git a/source4/torture/ndr/ndr.c b/source4/torture/ndr/ndr.c index 5c7dfc7c29..18ede54867 100644 --- a/source4/torture/ndr/ndr.c +++ b/source4/torture/ndr/ndr.c @@ -36,7 +36,7 @@ static bool wrap_ndr_pull_test(struct torture_context *tctx, struct torture_test *test) { bool (*check_fn) (struct torture_context *ctx, void *data) = test->fn; - const struct ndr_pull_test_data *data = test->data; + const struct ndr_pull_test_data *data = (const struct ndr_pull_test_data *)test->data; void *ds = talloc_zero_size(tctx, data->struct_size); struct ndr_pull *ndr = ndr_pull_init_blob(&(data->data), tctx); diff --git a/source4/torture/ndr/winreg.c b/source4/torture/ndr/winreg.c index d7c956efd6..ab256a7152 100644 --- a/source4/torture/ndr/winreg.c +++ b/source4/torture/ndr/winreg.c @@ -240,7 +240,7 @@ static const uint8_t querymultiplevalues_in_data[] = { }; static bool querymultiplevalues_in_check(struct torture_context *tctx, - struct winreg_QueryMultipleValues *r) + struct winreg_QueryMultipleValues *r) { torture_assert_int_equal(tctx, r->in.num_values, 1, "num values"); torture_assert_str_equal(tctx, r->in.values[0].name->name, "HOMEPATH", @@ -272,7 +272,7 @@ static const uint8_t querymultiplevalues_out_data[] = { }; static bool querymultiplevalues_out_check(struct torture_context *tctx, - struct winreg_QueryMultipleValues *r) + struct winreg_QueryMultipleValues *r) { torture_assert_str_equal(tctx, r->out.values[0].name->name, "HOMEPATH", "name"); @@ -458,7 +458,7 @@ static const uint8_t getkeysecurity_in_data[] = { }; static bool getkeysecurity_in_check(struct torture_context *tctx, - struct winreg_GetKeySecurity *r) + struct winreg_GetKeySecurity *r) { /* FIXME: Handle */ torture_assert_int_equal(tctx, r->in.sec_info, 2, "sec info"); @@ -476,7 +476,7 @@ static const uint8_t getkeysecurity_out_data[] = { }; static bool getkeysecurity_out_check(struct torture_context *tctx, - struct winreg_GetKeySecurity *r) + struct winreg_GetKeySecurity *r) { torture_assert_int_equal(tctx, r->in.sd->size, 20, "sd size"); torture_assert_int_equal(tctx, r->in.sd->len, 20, "sd len"); diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c index bd05c0f38f..483b33dc11 100644 --- a/source4/torture/rap/rap.c +++ b/source4/torture/rap/rap.c @@ -155,7 +155,7 @@ static NTSTATUS rap_pull_string(TALLOC_CTX *mem_ctx, struct ndr_pull *ndr, if ( string_offset + len + 1 > ndr->data_size ) return NT_STATUS_INVALID_PARAMETER; - *dest = talloc_zero_size(mem_ctx, len+1); + *dest = talloc_zero_array(mem_ctx, char, len+1); pull_string(*dest, p, len+1, len, STR_ASCII); return NT_STATUS_OK; @@ -287,7 +287,7 @@ static NTSTATUS smbcli_rap_netshareenum(struct smbcli_tree *tree, return result; } -static BOOL test_netshareenum(struct smbcli_tree *tree) +static bool test_netshareenum(struct smbcli_tree *tree) { struct rap_NetShareEnum r; int i; @@ -297,7 +297,7 @@ static BOOL test_netshareenum(struct smbcli_tree *tree) r.in.bufsize = 8192; if (!NT_STATUS_IS_OK(smbcli_rap_netshareenum(tree, tmp_ctx, &r))) - return False; + return false; for (i=0; i<r.out.count; i++) { printf("%s %d %s\n", r.out.info[i].info1.name, @@ -307,7 +307,7 @@ static BOOL test_netshareenum(struct smbcli_tree *tree) talloc_free(tmp_ctx); - return True; + return true; } static NTSTATUS smbcli_rap_netserverenum2(struct smbcli_tree *tree, @@ -385,7 +385,7 @@ static NTSTATUS smbcli_rap_netserverenum2(struct smbcli_tree *tree, return result; } -static BOOL test_netserverenum(struct smbcli_tree *tree) +static bool test_netserverenum(struct smbcli_tree *tree) { struct rap_NetServerEnum2 r; int i; @@ -398,7 +398,7 @@ static BOOL test_netserverenum(struct smbcli_tree *tree) r.in.domain = NULL; if (!NT_STATUS_IS_OK(smbcli_rap_netserverenum2(tree, tmp_ctx, &r))) - return False; + return false; for (i=0; i<r.out.count; i++) { switch (r.in.level) { @@ -415,7 +415,7 @@ static BOOL test_netserverenum(struct smbcli_tree *tree) talloc_free(tmp_ctx); - return True; + return true; } _PUBLIC_ NTSTATUS smbcli_rap_netservergetinfo(struct smbcli_tree *tree, @@ -477,14 +477,14 @@ _PUBLIC_ NTSTATUS smbcli_rap_netservergetinfo(struct smbcli_tree *tree, return result; } -static BOOL test_netservergetinfo(struct smbcli_tree *tree) +static bool test_netservergetinfo(struct smbcli_tree *tree) { struct rap_WserverGetInfo r; - BOOL res = True; + bool res = true; TALLOC_CTX *mem_ctx; if (!(mem_ctx = talloc_new(tree))) { - return False; + return false; } r.in.bufsize = 0xffff; @@ -498,9 +498,9 @@ static BOOL test_netservergetinfo(struct smbcli_tree *tree) return res; } -static BOOL test_rap(struct smbcli_tree *tree) +static bool test_rap(struct smbcli_tree *tree) { - BOOL res = True; + bool res = true; res &= test_netserverenum(tree); res &= test_netshareenum(tree); @@ -509,20 +509,20 @@ static BOOL test_rap(struct smbcli_tree *tree) return res; } -BOOL torture_rap_basic(struct torture_context *torture) +bool torture_rap_basic(struct torture_context *torture) { struct smbcli_state *cli; - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx; if (!torture_open_connection(&cli, 0)) { - return False; + return false; } mem_ctx = talloc_init("torture_rap_basic"); if (!test_rap(cli->tree)) { - ret = False; + ret = false; } torture_close_connection(cli); @@ -531,7 +531,7 @@ BOOL torture_rap_basic(struct torture_context *torture) return ret; } -BOOL torture_rap_scan(struct torture_context *torture) +bool torture_rap_scan(struct torture_context *torture) { TALLOC_CTX *mem_ctx; struct smbcli_state *cli; @@ -540,7 +540,7 @@ BOOL torture_rap_scan(struct torture_context *torture) mem_ctx = talloc_init("torture_rap_scan"); if (!torture_open_connection(&cli, 0)) { - return False; + return false; } for (callno = 0; callno < 0xffff; callno++) { @@ -557,7 +557,7 @@ BOOL torture_rap_scan(struct torture_context *torture) torture_close_connection(cli); - return True; + return true; } NTSTATUS torture_rap_init(void) diff --git a/source4/torture/raw/acls.c b/source4/torture/raw/acls.c index 026384cb8b..2c3f4a52c6 100644 --- a/source4/torture/raw/acls.c +++ b/source4/torture/raw/acls.c @@ -35,7 +35,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -46,7 +46,7 @@ static bool test_sd(struct torture_context *tctx, NTSTATUS status; union smb_open io; const char *fname = BASEDIR "\\sd.txt"; - BOOL ret = True; + bool ret = true; int fnum = -1; union smb_fileinfo q; union smb_setfileinfo set; @@ -113,7 +113,7 @@ static bool test_sd(struct torture_context *tctx, NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd); - ret = False; + ret = false; } printf("remove it again\n"); @@ -226,7 +226,7 @@ static bool test_nttrans_create(struct torture_context *tctx, NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd); - ret = False; + ret = false; } done: @@ -243,7 +243,7 @@ done: if (_q.access_information.out.access_flags != (flags)) { \ printf("(%s) Incorrect access_flags 0x%08x - should be 0x%08x\n", \ __location__, _q.access_information.out.access_flags, (flags)); \ - ret = False; \ + ret = false; \ goto done; \ } \ } while (0) @@ -259,7 +259,7 @@ static bool test_creator_sid(struct torture_context *tctx, NTSTATUS status; union smb_open io; const char *fname = BASEDIR "\\creator.txt"; - BOOL ret = True; + bool ret = true; int fnum = -1; union smb_fileinfo q; union smb_setfileinfo set; @@ -358,7 +358,7 @@ static bool test_creator_sid(struct torture_context *tctx, NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd); - ret = False; + ret = false; } printf("try open for write\n"); @@ -418,7 +418,7 @@ static bool test_creator_sid(struct torture_context *tctx, NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd2); - ret = False; + ret = false; } @@ -471,7 +471,7 @@ static bool test_generic_bits(struct torture_context *tctx, NTSTATUS status; union smb_open io; const char *fname = BASEDIR "\\generic.txt"; - BOOL ret = True; + bool ret = true; int fnum = -1, i; union smb_fileinfo q; union smb_setfileinfo set; @@ -499,8 +499,8 @@ static bool test_generic_bits(struct torture_context *tctx, { SEC_GENERIC_EXECUTE, SEC_RIGHTS_DIR_EXECUTE }, { SEC_GENERIC_ALL, SEC_RIGHTS_DIR_ALL } }; - BOOL has_restore_privilege; - BOOL has_take_ownership_privilege; + bool has_restore_privilege; + bool has_take_ownership_privilege; printf("TESTING FILE GENERIC BITS\n"); @@ -599,7 +599,7 @@ static bool test_generic_bits(struct torture_context *tctx, NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd2); - ret = False; + ret = false; } io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -647,7 +647,7 @@ static bool test_generic_bits(struct torture_context *tctx, NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd2); - ret = False; + ret = false; } io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -764,7 +764,7 @@ static bool test_generic_bits(struct torture_context *tctx, NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd2); - ret = False; + ret = false; } io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -812,7 +812,7 @@ static bool test_generic_bits(struct torture_context *tctx, NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd2); - ret = False; + ret = false; } io.ntcreatex.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -846,14 +846,14 @@ static bool test_owner_bits(struct torture_context *tctx, NTSTATUS status; union smb_open io; const char *fname = BASEDIR "\\generic.txt"; - BOOL ret = True; + bool ret = true; int fnum = -1, i; union smb_fileinfo q; union smb_setfileinfo set; struct security_descriptor *sd, *sd_orig; const char *owner_sid; - BOOL has_restore_privilege; - BOOL has_take_ownership_privilege; + bool has_restore_privilege; + bool has_take_ownership_privilege; uint32_t expected_bits; printf("TESTING FILE OWNER BITS\n"); @@ -966,7 +966,7 @@ static bool test_inheritance(struct torture_context *tctx, const char *dname = BASEDIR "\\inheritance"; const char *fname1 = BASEDIR "\\inheritance\\testfile"; const char *fname2 = BASEDIR "\\inheritance\\testdir"; - BOOL ret = True; + bool ret = true; int fnum=0, fnum2, i; union smb_fileinfo q; union smb_setfileinfo set; @@ -1175,7 +1175,7 @@ static bool test_inheritance(struct torture_context *tctx, sd_orig->owner_sid)) { printf("Bad sd in child file at %d\n", i); NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); - ret = False; + ret = false; goto check_dir; } @@ -1186,7 +1186,7 @@ static bool test_inheritance(struct torture_context *tctx, test_flags[i].file_flags, test_flags[i].parent_flags, i); - ret = False; + ret = false; } check_dir: @@ -1224,7 +1224,7 @@ static bool test_inheritance(struct torture_context *tctx, printf("Bad sd in child dir at %d (parent 0x%x)\n", i, test_flags[i].parent_flags); NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); - ret = False; + ret = false; continue; } } else if (test_flags[i].parent_flags & SEC_ACE_FLAG_CONTAINER_INHERIT) { @@ -1242,7 +1242,7 @@ static bool test_inheritance(struct torture_context *tctx, printf("Bad sd in child dir at %d (parent 0x%x)\n", i, test_flags[i].parent_flags); NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); - ret = False; + ret = false; continue; } } else { @@ -1255,7 +1255,7 @@ static bool test_inheritance(struct torture_context *tctx, printf("Bad sd in child dir at %d (parent 0x%x)\n", i, test_flags[i].parent_flags); NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); - ret = False; + ret = false; continue; } } @@ -1308,7 +1308,7 @@ static bool test_inheritance(struct torture_context *tctx, NDR_PRINT_DEBUG(security_descriptor, q.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd2); - ret = False; + ret = false; } io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; @@ -1316,7 +1316,7 @@ static bool test_inheritance(struct torture_context *tctx, status = smb_raw_open(cli->tree, tctx, &io); if (NT_STATUS_IS_OK(status)) { printf("failed: w2k3 ACL bug (allowed open when ACL should deny)\n"); - ret = False; + ret = false; fnum2 = io.ntcreatex.out.file.fnum; CHECK_ACCESS_FLAGS(fnum2, SEC_RIGHTS_FILE_ALL); smbcli_close(cli->tree, fnum2); @@ -1382,14 +1382,14 @@ done: /* test dynamic acl inheritance */ -static BOOL test_inheritance_dynamic(struct torture_context *tctx, +static bool test_inheritance_dynamic(struct torture_context *tctx, struct smbcli_state *cli) { NTSTATUS status; union smb_open io; const char *dname = BASEDIR "\\inheritance"; const char *fname1 = BASEDIR "\\inheritance\\testfile"; - BOOL ret = True; + bool ret = true; int fnum=0, fnum2; union smb_fileinfo q; union smb_setfileinfo set; @@ -1399,7 +1399,7 @@ static BOOL test_inheritance_dynamic(struct torture_context *tctx, printf("TESTING DYNAMIC ACL INHERITANCE\n"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } io.generic.level = RAW_OPEN_NTCREATEX; @@ -1533,14 +1533,14 @@ done: if (!(granted & access)) {\ printf("(%s) %s but flags 0x%08X are not granted! granted[0x%08X] desired[0x%08X]\n", \ __location__, nt_errstr(status), access, granted, desired); \ - ret = False; \ + ret = false; \ goto done; \ } \ } else { \ if (granted & access) {\ printf("(%s) %s but flags 0x%08X are granted! granted[0x%08X] desired[0x%08X]\n", \ __location__, nt_errstr(status), access, granted, desired); \ - ret = False; \ + ret = false; \ goto done; \ } \ } \ @@ -1552,7 +1552,7 @@ static bool test_sd_get_set(struct torture_context *tctx, struct smbcli_state *cli) { NTSTATUS status; - BOOL ret = True; + bool ret = true; union smb_open io; union smb_fileinfo fi; union smb_setfileinfo si; @@ -1736,7 +1736,7 @@ done: */ bool torture_raw_acls(struct torture_context *tctx, struct smbcli_state *cli) { - BOOL ret = True; + bool ret = true; if (!torture_setup_dir(cli, BASEDIR)) { return false; diff --git a/source4/torture/raw/chkpath.c b/source4/torture/raw/chkpath.c index a56afee546..42a3c3cebe 100644 --- a/source4/torture/raw/chkpath.c +++ b/source4/torture/raw/chkpath.c @@ -29,7 +29,7 @@ if (!NT_STATUS_EQUAL(status, correct) && !NT_STATUS_EQUAL(status, dos_correct)) { \ printf("(%d) Incorrect status %s - should be %s\n", \ __LINE__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -54,7 +54,7 @@ static NTSTATUS single_search(struct smbcli_state *cli, return status; } -static BOOL test_path(struct smbcli_state *cli, const char *path, NTSTATUS expected, NTSTATUS dos_expected) +static bool test_path(struct smbcli_state *cli, const char *path, NTSTATUS expected, NTSTATUS dos_expected) { union smb_chkpath io; NTSTATUS status; @@ -63,19 +63,19 @@ static BOOL test_path(struct smbcli_state *cli, const char *path, NTSTATUS expec if (!NT_STATUS_EQUAL(status, expected) && !NT_STATUS_EQUAL(status, dos_expected)) { printf("%-40s FAILED %s should be %s or %s\n", path, nt_errstr(status), nt_errstr(expected), nt_errstr(dos_expected)); - return False; + return false; } else { printf("%-40s correct (%s)\n", path, nt_errstr(status)); } - return True; + return true; } -static BOOL test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_chkpath io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum = -1; int fnum1 = -1; @@ -89,7 +89,7 @@ static BOOL test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) fnum = create_complex_file(cli, mem_ctx, BASEDIR "\\test.txt.."); if (fnum == -1) { printf("failed to open test.txt - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -97,7 +97,7 @@ static BOOL test_chkpath(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (!torture_set_file_attribute(cli->tree, BASEDIR, FILE_ATTRIBUTE_HIDDEN)) { printf("failed to set basedir hidden\n"); - ret = False; + ret = false; goto done; } @@ -215,34 +215,34 @@ done: basic testing of chkpath calls */ bool torture_raw_chkpath(struct torture_context *torture, - struct smbcli_state *cli) + struct smbcli_state *cli) { bool ret = true; int fnum; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt"))) { printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\V S"))) { printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, BASEDIR "\\nt\\V S\\VB98"))) { printf("Failed to create " BASEDIR " - %s\n", smbcli_errstr(cli->tree)); - return False; + return false; } fnum = create_complex_file(cli, torture, BASEDIR "\\nt\\V S\\VB98\\vb6.exe"); if (fnum == -1) { printf("failed to open \\nt\\V S\\VB98\\vb6.exe - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } diff --git a/source4/torture/raw/close.c b/source4/torture/raw/close.c index 34ac2f0db8..6f139f8530 100644 --- a/source4/torture/raw/close.c +++ b/source4/torture/raw/close.c @@ -28,7 +28,7 @@ * basic testing of all RAW_CLOSE_* calls */ bool torture_raw_close(struct torture_context *torture, - struct smbcli_state *cli) + struct smbcli_state *cli) { bool ret = true; union smb_close io; diff --git a/source4/torture/raw/composite.c b/source4/torture/raw/composite.c index 374ff3cb98..c6969574a8 100644 --- a/source4/torture/raw/composite.c +++ b/source4/torture/raw/composite.c @@ -30,6 +30,7 @@ #include "librpc/gen_ndr/ndr_misc.h" #include "lib/cmdline/popt_common.h" #include "torture/util.h" +#include "param/param.h" #define BASEDIR "\\composite" @@ -42,7 +43,7 @@ static void loadfile_complete(struct composite_context *c) /* test a simple savefile/loadfile combination */ -static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { const char *fname = BASEDIR "\\test.txt"; NTSTATUS status; @@ -67,8 +68,8 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_composite_savefile(cli->tree, &io1); if (!NT_STATUS_IS_OK(status)) { - printf("savefile failed: %s\n", nt_errstr(status)); - return False; + printf("(%s) savefile failed: %s\n", __location__,nt_errstr(status)); + return false; } io2.in.fname = fname; @@ -86,8 +87,8 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("waiting for completion\n"); while (*count != num_ops) { event_loop_once(cli->transport->socket->event.ctx); - if (lp_parm_bool(-1, "torture", "progress", true)) { - printf("count=%d\r", *count); + if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) { + printf("(%s) count=%d\r", __location__, *count); fflush(stdout); } } @@ -96,31 +97,31 @@ static BOOL test_loadfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) for (i=0;i<num_ops;i++) { status = smb_composite_loadfile_recv(c[i], mem_ctx); if (!NT_STATUS_IS_OK(status)) { - printf("loadfile[%d] failed - %s\n", i, nt_errstr(status)); - return False; + printf("(%s) loadfile[%d] failed - %s\n", __location__, i, nt_errstr(status)); + return false; } if (io2.out.size != len) { - printf("wrong length in returned data - %d should be %d\n", + printf("(%s) wrong length in returned data - %d should be %d\n",__location__, io2.out.size, (int)len); - return False; + return false; } if (memcmp(io2.out.data, data, len) != 0) { - printf("wrong data in loadfile!\n"); - return False; + printf("(%s) wrong data in loadfile!\n",__location__); + return false; } } talloc_free(data); - return True; + return true; } /* test a simple savefile/loadfile combination */ -static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { const char *fname = BASEDIR "\\test.txt"; NTSTATUS status; @@ -133,7 +134,7 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) extern int torture_numops; struct event_context *event_ctx; int *count = talloc_zero(mem_ctx, int); - BOOL ret = True; + bool ret = true; data = talloc_array(mem_ctx, uint8_t, len); @@ -147,18 +148,18 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_composite_savefile(cli->tree, &io1); if (!NT_STATUS_IS_OK(status)) { - printf("savefile failed: %s\n", nt_errstr(status)); - return False; + printf("(%s) savefile failed: %s\n",__location__, nt_errstr(status)); + return false; } - io2.in.dest_host = lp_parm_string(-1, "torture", "host"); + io2.in.dest_host = lp_parm_string(global_loadparm, NULL, "torture", "host"); io2.in.port = 0; - io2.in.called_name = lp_parm_string(-1, "torture", "host"); - io2.in.service = lp_parm_string(-1, "torture", "share"); + io2.in.called_name = lp_parm_string(global_loadparm, NULL, "torture", "host"); + io2.in.service = lp_parm_string(global_loadparm, NULL, "torture", "share"); io2.in.service_type = "A:"; io2.in.credentials = cmdline_credentials; - io2.in.workgroup = lp_workgroup(); + io2.in.workgroup = lp_workgroup(global_loadparm); io2.in.filename = fname; printf("testing parallel fetchfile with %d ops\n", torture_numops); @@ -176,8 +177,8 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) while (*count != torture_numops) { event_loop_once(event_ctx); - if (lp_parm_bool(-1, "torture", "progress", true)) { - printf("count=%d\r", *count); + if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) { + printf("(%s) count=%d\r", __location__, *count); fflush(stdout); } } @@ -186,23 +187,23 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) for (i=0;i<torture_numops;i++) { status = smb_composite_fetchfile_recv(c[i], mem_ctx); if (!NT_STATUS_IS_OK(status)) { - printf("loadfile[%d] failed - %s\n", i, + printf("(%s) loadfile[%d] failed - %s\n", __location__, i, nt_errstr(status)); - ret = False; + ret = false; continue; } if (io2.out.size != len) { - printf("wrong length in returned data - %d " - "should be %d\n", + printf("(%s) wrong length in returned data - %d " + "should be %d\n", __location__, io2.out.size, (int)len); - ret = False; + ret = false; continue; } if (memcmp(io2.out.data, data, len) != 0) { - printf("wrong data in loadfile!\n"); - ret = False; + printf("(%s) wrong data in loadfile!\n", __location__); + ret = false; continue; } } @@ -213,7 +214,7 @@ static BOOL test_fetchfile(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* test setfileacl */ -static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { struct smb_composite_appendacl **io; struct smb_composite_appendacl **io_orig; @@ -242,8 +243,8 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_composite_savefile(cli->tree, &io1); if (!NT_STATUS_IS_OK(status)) { - printf("savefile failed: %s\n", nt_errstr(status)); - return False; + printf("(%s) savefile failed: %s\n", __location__, nt_errstr(status)); + return false; } io_orig[i] = talloc (io_orig, struct smb_composite_appendacl); @@ -251,8 +252,8 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io_orig[i]->in.sd = security_descriptor_initialise(io_orig[i]); status = smb_composite_appendacl(cli->tree, io_orig[i], io_orig[i]); if (!NT_STATUS_IS_OK(status)) { - printf("appendacl failed: %s\n", nt_errstr(status)); - return False; + printf("(%s) appendacl failed: %s\n", __location__, nt_errstr(status)); + return false; } } @@ -271,8 +272,8 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = security_descriptor_dacl_add(test_sd, ace); if (!NT_STATUS_IS_OK(status)) { - printf("appendacl failed: %s\n", nt_errstr(status)); - return False; + printf("(%s) appendacl failed: %s\n", __location__, nt_errstr(status)); + return false; } /* set parameters for appendacl async call */ @@ -296,8 +297,8 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("waiting for completion\n"); while (*count != num_ops) { event_loop_once(event_ctx); - if (lp_parm_bool(-1, "torture", "progress", true)) { - printf("count=%d\r", *count); + if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) { + printf("(%s) count=%d\r", __location__, *count); fflush(stdout); } } @@ -306,14 +307,14 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) for (i=0; i < num_ops; i++) { status = smb_composite_appendacl_recv(c[i], io[i]); if (!NT_STATUS_IS_OK(status)) { - printf("appendacl[%d] failed - %s\n", i, nt_errstr(status)); - return False; + printf("(%s) appendacl[%d] failed - %s\n", __location__, i, nt_errstr(status)); + return false; } security_descriptor_dacl_add(io_orig[i]->out.sd, ace); if (!security_acl_equal(io_orig[i]->out.sd->dacl, io[i]->out.sd->dacl)) { - printf("appendacl[%d] failed - needed acl isn't set\n", i); - return False; + printf("(%s) appendacl[%d] failed - needed acl isn't set\n", __location__, i); + return false; } } @@ -322,11 +323,11 @@ static BOOL test_appendacl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) talloc_free (test_sid); talloc_free (test_sd); - return True; + return true; } /* test a query FS info by asking for share's GUID */ -static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { char *guid = NULL; NTSTATUS status; @@ -337,15 +338,15 @@ static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) extern int torture_numops; struct event_context *event_ctx; int *count = talloc_zero(mem_ctx, int); - BOOL ret = True; + bool ret = true; - io1.in.dest_host = lp_parm_string(-1, "torture", "host"); + io1.in.dest_host = lp_parm_string(global_loadparm, NULL, "torture", "host"); io1.in.port = 0; - io1.in.called_name = lp_parm_string(-1, "torture", "host"); - io1.in.service = lp_parm_string(-1, "torture", "share"); + io1.in.called_name = lp_parm_string(global_loadparm, NULL, "torture", "host"); + io1.in.service = lp_parm_string(global_loadparm, NULL, "torture", "share"); io1.in.service_type = "A:"; io1.in.credentials = cmdline_credentials; - io1.in.workgroup = lp_workgroup(); + io1.in.workgroup = lp_workgroup(global_loadparm); io1.in.level = RAW_QFS_OBJECTID_INFORMATION; printf("testing parallel queryfsinfo [Object ID] with %d ops\n", torture_numops); @@ -363,8 +364,8 @@ static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) while (*count < torture_numops) { event_loop_once(event_ctx); - if (lp_parm_bool(-1, "torture", "progress", true)) { - printf("count=%d\r", *count); + if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) { + printf("(%s) count=%d\r", __location__, *count); fflush(stdout); } } @@ -373,16 +374,16 @@ static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) for (i=0;i<torture_numops;i++) { status = smb_composite_fsinfo_recv(c[i], mem_ctx); if (!NT_STATUS_IS_OK(status)) { - printf("fsinfo[%d] failed - %s\n", i, nt_errstr(status)); - ret = False; + printf("(%s) fsinfo[%d] failed - %s\n", __location__, i, nt_errstr(status)); + ret = false; continue; } if (io1.out.fsinfo->generic.level != RAW_QFS_OBJECTID_INFORMATION) { - printf("wrong level in returned info - %d " - "should be %d\n", + printf("(%s) wrong level in returned info - %d " + "should be %d\n", __location__, io1.out.fsinfo->generic.level, RAW_QFS_OBJECTID_INFORMATION); - ret = False; + ret = false; continue; } @@ -400,12 +401,12 @@ static BOOL test_fsinfo(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) basic testing of libcli composite calls */ bool torture_raw_composite(struct torture_context *tctx, - struct smbcli_state *cli) + struct smbcli_state *cli) { bool ret = true; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } ret &= test_fetchfile(cli, tctx); diff --git a/source4/torture/raw/context.c b/source4/torture/raw/context.c index df7f5f3851..11ad11ab3f 100644 --- a/source4/torture/raw/context.c +++ b/source4/torture/raw/context.c @@ -27,6 +27,7 @@ #include "libcli/libcli.h" #include "torture/util.h" #include "auth/credentials/credentials.h" +#include "param/param.h" #define BASEDIR "\\rawcontext" @@ -34,7 +35,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -42,7 +43,7 @@ if ((v) != (correct)) { \ printf("(%s) Incorrect value %s=%d - should be %d\n", \ __location__, #v, v, correct); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -50,7 +51,7 @@ if ((v) == (correct)) { \ printf("(%s) Incorrect value %s=%d - should not be %d\n", \ __location__, #v, v, correct); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -58,10 +59,10 @@ /* test session ops */ -static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct smbcli_session *session; struct smbcli_session *session2; struct smbcli_session *session3; @@ -83,15 +84,15 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("TESTING SESSION HANDLING\n"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("create a second security context on the same transport\n"); - session = smbcli_session_init(cli->transport, mem_ctx, False); + session = smbcli_session_init(cli->transport, mem_ctx, false); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ - setup.in.workgroup = lp_workgroup(); + setup.in.workgroup = lp_workgroup(global_loadparm); setup.in.credentials = cmdline_credentials; @@ -101,12 +102,12 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) session->vuid = setup.out.vuid; printf("create a third security context on the same transport, with vuid set\n"); - session2 = smbcli_session_init(cli->transport, mem_ctx, False); + session2 = smbcli_session_init(cli->transport, mem_ctx, false); session2->vuid = session->vuid; setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ - setup.in.workgroup = lp_workgroup(); + setup.in.workgroup = lp_workgroup(global_loadparm); setup.in.credentials = cmdline_credentials; @@ -128,12 +129,12 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (cli->transport->negotiate.capabilities & CAP_EXTENDED_SECURITY) { printf("create a fourth security context on the same transport, without extended security\n"); - session3 = smbcli_session_init(cli->transport, mem_ctx, False); + session3 = smbcli_session_init(cli->transport, mem_ctx, false); session3->vuid = session->vuid; setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */ - setup.in.workgroup = lp_workgroup(); + setup.in.workgroup = lp_workgroup(global_loadparm); setup.in.credentials = cmdline_credentials; @@ -142,15 +143,15 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_LOGON_FAILURE); printf("create a fouth anonymous security context on the same transport, without extended security\n"); - session4 = smbcli_session_init(cli->transport, mem_ctx, False); + session4 = smbcli_session_init(cli->transport, mem_ctx, false); session4->vuid = session->vuid; setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities &= ~CAP_EXTENDED_SECURITY; /* force a non extended security login (should fail) */ - setup.in.workgroup = lp_workgroup(); + setup.in.workgroup = lp_workgroup(global_loadparm); anon_creds = cli_credentials_init(mem_ctx); - cli_credentials_set_conf(anon_creds); + cli_credentials_set_conf(anon_creds, global_loadparm); cli_credentials_set_anonymous(anon_creds); setup.in.credentials = anon_creds; @@ -162,7 +163,7 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) } printf("use the same tree as the existing connection\n"); - tree = smbcli_tree_init(session, mem_ctx, False); + tree = smbcli_tree_init(session, mem_ctx, false); tree->tid = cli->tree->tid; printf("create a file using the new vuid\n"); @@ -224,11 +225,11 @@ static BOOL test_session(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) for (i=0; i <ARRAY_SIZE(sessions); i++) { setups[i].in.sesskey = cli->transport->negotiate.sesskey; setups[i].in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ - setups[i].in.workgroup = lp_workgroup(); + setups[i].in.workgroup = lp_workgroup(global_loadparm); setups[i].in.credentials = cmdline_credentials; - sessions[i] = smbcli_session_init(cli->transport, mem_ctx, False); + sessions[i] = smbcli_session_init(cli->transport, mem_ctx, false); composite_contexts[i] = smb_composite_sesssetup_send(sessions[i], &setups[i]); } @@ -256,10 +257,10 @@ done: /* test tree ops */ -static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; - BOOL ret = True; + bool ret = true; const char *share, *host; struct smbcli_tree *tree; union smb_tcon tcon; @@ -273,14 +274,14 @@ static BOOL test_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("TESTING TREE HANDLING\n"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } - share = lp_parm_string(-1, "torture", "share"); - host = lp_parm_string(-1, "torture", "host"); + share = lp_parm_string(global_loadparm, NULL, "torture", "share"); + host = lp_parm_string(global_loadparm, NULL, "torture", "host"); printf("create a second tree context on the same session\n"); - tree = smbcli_tree_init(cli->session, mem_ctx, False); + tree = smbcli_tree_init(cli->session, mem_ctx, false); tcon.generic.level = RAW_TCON_TCONX; tcon.tconx.in.flags = 0; @@ -361,10 +362,10 @@ done: this demonstrates that a tcon isn't autoclosed by a ulogoff the tcon can be reused using any other valid session later */ -static BOOL test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; - BOOL ret = True; + bool ret = true; const char *share, *host; struct smbcli_session *session1; struct smbcli_session *session2; @@ -381,17 +382,17 @@ static BOOL test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("TESTING TREE with ulogoff\n"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } - share = lp_parm_string(-1, "torture", "share"); - host = lp_parm_string(-1, "torture", "host"); + share = lp_parm_string(global_loadparm, NULL, "torture", "share"); + host = lp_parm_string(global_loadparm, NULL, "torture", "host"); printf("create the first new sessions\n"); - session1 = smbcli_session_init(cli->transport, mem_ctx, False); + session1 = smbcli_session_init(cli->transport, mem_ctx, false); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; - setup.in.workgroup = lp_workgroup(); + setup.in.workgroup = lp_workgroup(global_loadparm); setup.in.credentials = cmdline_credentials; status = smb_composite_sesssetup(session1, &setup); CHECK_STATUS(status, NT_STATUS_OK); @@ -399,7 +400,7 @@ static BOOL test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("vuid1=%d\n", session1->vuid); printf("create a tree context on the with vuid1\n"); - tree = smbcli_tree_init(session1, mem_ctx, False); + tree = smbcli_tree_init(session1, mem_ctx, false); tcon.generic.level = RAW_TCON_TCONX; tcon.tconx.in.flags = 0; tcon.tconx.in.password = data_blob(NULL, 0); @@ -444,10 +445,10 @@ static BOOL test_tree_ulogoff(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) CHECK_STATUS(status, NT_STATUS_OK); printf("create the second new sessions\n"); - session2 = smbcli_session_init(cli->transport, mem_ctx, False); + session2 = smbcli_session_init(cli->transport, mem_ctx, false); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; - setup.in.workgroup = lp_workgroup(); + setup.in.workgroup = lp_workgroup(global_loadparm); setup.in.credentials = cmdline_credentials; status = smb_composite_sesssetup(session2, &setup); CHECK_STATUS(status, NT_STATUS_OK); @@ -511,10 +512,10 @@ done: this test demonstrates that exit() only sees the PID used for the open() calls */ -static BOOL test_pid_exit_only_sees_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_pid_exit_only_sees_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; - BOOL ret = True; + bool ret = true; union smb_open io; union smb_write wr; union smb_close cl; @@ -526,7 +527,7 @@ static BOOL test_pid_exit_only_sees_open(struct smbcli_state *cli, TALLOC_CTX *m printf("TESTING PID HANDLING exit() only cares about open() PID\n"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } pid1 = cli->session->pid; @@ -619,10 +620,10 @@ done: /* test pid ops with 2 sessions */ -static BOOL test_pid_2sess(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_pid_2sess(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct smbcli_session *session; struct smb_composite_sesssetup setup; union smb_open io; @@ -636,15 +637,15 @@ static BOOL test_pid_2sess(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("TESTING PID HANDLING WITH 2 SESSIONS\n"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("create a second security context on the same transport\n"); - session = smbcli_session_init(cli->transport, mem_ctx, False); + session = smbcli_session_init(cli->transport, mem_ctx, false); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; /* ignored in secondary session setup, except by our libs, which care about the extended security bit */ - setup.in.workgroup = lp_workgroup(); + setup.in.workgroup = lp_workgroup(global_loadparm); setup.in.credentials = cmdline_credentials; @@ -723,10 +724,10 @@ done: /* test pid ops with 2 tcons */ -static BOOL test_pid_2tcon(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_pid_2tcon(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; - BOOL ret = True; + bool ret = true; const char *share, *host; struct smbcli_tree *tree; union smb_tcon tcon; @@ -742,14 +743,14 @@ static BOOL test_pid_2tcon(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("TESTING PID HANDLING WITH 2 TCONS\n"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } - share = lp_parm_string(-1, "torture", "share"); - host = lp_parm_string(-1, "torture", "host"); + share = lp_parm_string(global_loadparm, NULL, "torture", "share"); + host = lp_parm_string(global_loadparm, NULL, "torture", "host"); printf("create a second tree context on the same session\n"); - tree = smbcli_tree_init(cli->session, mem_ctx, False); + tree = smbcli_tree_init(cli->session, mem_ctx, false); tcon.generic.level = RAW_TCON_TCONX; tcon.tconx.in.flags = 0; @@ -868,7 +869,7 @@ done: static bool torture_raw_context_int(struct torture_context *tctx, struct smbcli_state *cli) { - BOOL ret = True; + bool ret = true; ret &= test_session(cli, tctx); ret &= test_tree(cli, tctx); @@ -886,12 +887,12 @@ static bool torture_raw_context_int(struct torture_context *tctx, basic testing of session/tree context calls */ bool torture_raw_context(struct torture_context *torture, - struct smbcli_state *cli) + struct smbcli_state *cli) { bool ret = true; - if (lp_use_spnego()) { + if (lp_use_spnego(global_loadparm)) { ret &= torture_raw_context_int(torture, cli); - lp_set_cmdline("use spnego", "False"); + lp_set_cmdline(global_loadparm, "use spnego", "False"); } ret &= torture_raw_context_int(torture, cli); diff --git a/source4/torture/raw/eas.c b/source4/torture/raw/eas.c index 7e9c742943..b24b98796f 100644 --- a/source4/torture/raw/eas.c +++ b/source4/torture/raw/eas.c @@ -25,6 +25,7 @@ #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" #include "torture/util.h" +#include "param/param.h" #define BASEDIR "\\testeas" @@ -32,26 +33,26 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) -static BOOL maxeadebug; /* need that here, to allow no file delete in debug case */ +static bool maxeadebug; /* need that here, to allow no file delete in debug case */ -static BOOL check_ea(struct smbcli_state *cli, +static bool check_ea(struct smbcli_state *cli, const char *fname, const char *eaname, const char *value) { NTSTATUS status = torture_check_ea(cli, fname, eaname, value); return NT_STATUS_IS_OK(status); } -static BOOL test_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; union smb_setfileinfo setfile; union smb_open io; const char *fname = BASEDIR "\\ea.txt"; - BOOL ret = True; + bool ret = true; int fnum = -1; printf("TESTING SETFILEINFO EA_SET\n"); @@ -207,7 +208,7 @@ static int test_one_eamax(struct smbcli_state *cli, const int fnum, } i -= (high - low + 1) / 2; } - } while (True); + } while (true); return low; } @@ -221,21 +222,21 @@ static int test_one_eamax(struct smbcli_state *cli, const int fnum, * maxeasize 65536 limit the max. size for a single EA name * maxeanames 101 limit of the number of tested names * maxeastart 1 this EA size is used to test for the 1st EA (atm) - * maxeadebug 0 if set True, further debug output is done - in addition + * maxeadebug 0 if set true, further debug output is done - in addition * the testfile is not deleted for further inspection! * * Set some/all of these options on the cmdline with: * --option torture:maxeasize=1024 --option torture:maxeadebug=1 ... * */ -static BOOL test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; union smb_open io; const char *fname = BASEDIR "\\ea_max.txt"; int fnum = -1; - BOOL ret = True; - BOOL err = False; + bool ret = true; + bool err = false; int i, j, k, last, total; DATA_BLOB eablob; @@ -246,27 +247,27 @@ static BOOL test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("TESTING SETFILEINFO MAX. EA_SET\n"); - maxeasize = lp_parm_int(-1, "torture", "maxeasize", 65536); - maxeanames = lp_parm_int(-1, "torture", "maxeanames", 101); - maxeastart = lp_parm_int(-1, "torture", "maxeastart", 1); - maxeadebug = lp_parm_int(-1, "torture", "maxeadebug", 0); + maxeasize = lp_parm_int(global_loadparm, NULL, "torture", "maxeasize", 65536); + maxeanames = lp_parm_int(global_loadparm, NULL, "torture", "maxeanames", 101); + maxeastart = lp_parm_int(global_loadparm, NULL, "torture", "maxeastart", 1); + maxeadebug = lp_parm_int(global_loadparm, NULL, "torture", "maxeadebug", 0); /* Do some sanity check on possibly passed parms */ if (maxeasize <= 0) { printf("Invalid parameter 'maxeasize=%d'",maxeasize); - err = True; + err = true; } if (maxeanames <= 0) { printf("Invalid parameter 'maxeanames=%d'",maxeanames); - err = True; + err = true; } if (maxeastart <= 0) { printf("Invalid parameter 'maxeastart=%d'",maxeastart); - err = True; + err = true; } if (maxeadebug < 0) { printf("Invalid parameter 'maxeadebug=%d'",maxeadebug); - err = True; + err = true; } if (err) { printf("\n\n"); @@ -352,7 +353,7 @@ static BOOL test_max_eas(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf ("NOTE: More EAs could be available!\n"); } if (total == 0) { - ret = False; + ret = false; } done: smbcli_close(cli->tree, fnum); @@ -362,12 +363,12 @@ done: /* test using NTTRANS CREATE to create a file with an initial EA set */ -static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; union smb_open io; const char *fname = BASEDIR "\\ea2.txt"; - BOOL ret = True; + bool ret = true; int fnum = -1; struct ea_struct eas[3]; struct smb_ea_list ea_list; @@ -446,10 +447,10 @@ done: */ bool torture_raw_eas(struct torture_context *torture, struct smbcli_state *cli) { - BOOL ret = True; + bool ret = true; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } ret &= test_eas(cli, torture); @@ -463,20 +464,20 @@ bool torture_raw_eas(struct torture_context *torture, struct smbcli_state *cli) /* test max EA size */ -BOOL torture_max_eas(struct torture_context *torture) +bool torture_max_eas(struct torture_context *torture) { struct smbcli_state *cli; - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx; if (!torture_open_connection(&cli, 0)) { - return False; + return false; } mem_ctx = talloc_init("torture_raw_eas"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } ret &= test_max_eas(cli, mem_ctx); diff --git a/source4/torture/raw/ioctl.c b/source4/torture/raw/ioctl.c index 8e98822e11..c4dd4c5bf2 100644 --- a/source4/torture/raw/ioctl.c +++ b/source4/torture/raw/ioctl.c @@ -31,18 +31,18 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%d) Incorrect status %s - should be %s\n", \ __LINE__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) /* test some ioctls */ -static BOOL test_ioctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_ioctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_ioctl ctl; int fnum; NTSTATUS status; - BOOL ret = True; + bool ret = true; const char *fname = BASEDIR "\\test.dat"; printf("TESTING IOCTL FUNCTIONS\n"); @@ -50,7 +50,7 @@ static BOOL test_ioctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) fnum = create_complex_file(cli, mem_ctx, fname); if (fnum == -1) { printf("Failed to create test.dat - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -81,11 +81,11 @@ done: } /* test some filesystem control functions */ -static BOOL test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { int fnum; NTSTATUS status; - BOOL ret = True; + bool ret = true; const char *fname = BASEDIR "\\test.dat"; union smb_ioctl nt; @@ -94,7 +94,7 @@ static BOOL test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) fnum = create_complex_file(cli, mem_ctx, fname); if (fnum == -1) { printf("Failed to create test.dat - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -102,7 +102,7 @@ static BOOL test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) nt.ioctl.level = RAW_IOCTL_NTIOCTL; nt.ntioctl.in.function = FSCTL_SET_SPARSE; nt.ntioctl.in.file.fnum = fnum; - nt.ntioctl.in.fsctl = True; + nt.ntioctl.in.fsctl = true; nt.ntioctl.in.filter = 0; nt.ntioctl.in.max_data = 0; nt.ntioctl.in.blob = data_blob(NULL, 0); @@ -114,7 +114,7 @@ static BOOL test_fsctl(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) nt.ioctl.level = RAW_IOCTL_NTIOCTL; nt.ntioctl.in.function = FSCTL_REQUEST_BATCH_OPLOCK; nt.ntioctl.in.file.fnum = fnum; - nt.ntioctl.in.fsctl = True; + nt.ntioctl.in.fsctl = true; nt.ntioctl.in.filter = 0; nt.ntioctl.in.max_data = 0; nt.ntioctl.in.blob = data_blob(NULL, 0); @@ -152,12 +152,12 @@ done: basic testing of some ioctl calls */ bool torture_raw_ioctl(struct torture_context *torture, - struct smbcli_state *cli) + struct smbcli_state *cli) { bool ret = true; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } ret &= test_ioctl(cli, torture); diff --git a/source4/torture/raw/lock.c b/source4/torture/raw/lock.c index 533974c9a9..c2d5a778fb 100644 --- a/source4/torture/raw/lock.c +++ b/source4/torture/raw/lock.c @@ -27,12 +27,13 @@ #include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" #include "lib/cmdline/popt_common.h" +#include "param/param.h" #define CHECK_STATUS(status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -46,12 +47,12 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli) { union smb_lock io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; const char *fname = BASEDIR "\\test.txt"; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_LOCK_LOCK\n"); @@ -60,7 +61,7 @@ static bool test_lock(struct torture_context *tctx, struct smbcli_state *cli) fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -182,12 +183,12 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli) union smb_lock io; struct smb_lock_entry lock[1]; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; const char *fname = BASEDIR "\\test.txt"; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_LOCK_LOCKX\n"); @@ -196,7 +197,7 @@ static bool test_lockx(struct torture_context *tctx, struct smbcli_state *cli) fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -362,13 +363,13 @@ static bool test_pidhigh(struct torture_context *tctx, union smb_lock io; struct smb_lock_entry lock[1]; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; const char *fname = BASEDIR "\\test.txt"; uint8_t c = 1; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing high pid\n"); @@ -379,13 +380,13 @@ static bool test_pidhigh(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } if (smbcli_write(cli->tree, fnum, 0, &c, 0, 1) != 1) { printf("Failed to write 1 byte - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -404,7 +405,7 @@ static bool test_pidhigh(struct torture_context *tctx, if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) { printf("Failed to read 1 byte - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -414,7 +415,7 @@ static bool test_pidhigh(struct torture_context *tctx, if (smbcli_read(cli->tree, fnum, &c, 0, 1) == 1) { printf("pid is incorrect handled for read with lock!\n"); - ret = False; + ret = false; goto done; } @@ -422,7 +423,7 @@ static bool test_pidhigh(struct torture_context *tctx, if (smbcli_read(cli->tree, fnum, &c, 0, 1) != 1) { printf("High pid is used on this server!\n"); - ret = False; + ret = false; } else { printf("High pid is not used on this server (correct)\n"); } @@ -449,14 +450,14 @@ static bool test_async(struct torture_context *tctx, union smb_lock io; struct smb_lock_entry lock[2]; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; const char *fname = BASEDIR "\\test.txt"; time_t t; struct smbcli_request *req; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing LOCKING_ANDX_CANCEL_LOCK\n"); @@ -465,7 +466,7 @@ static bool test_async(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -491,7 +492,7 @@ static bool test_async(struct torture_context *tctx, req = smb_raw_lock_send(cli->tree, &io); if (req == NULL) { printf("Failed to setup timed lock (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -522,7 +523,7 @@ static bool test_async(struct torture_context *tctx, if (time(NULL) > t+2) { printf("lock cancel was not immediate (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -538,7 +539,7 @@ static bool test_async(struct torture_context *tctx, req = smb_raw_lock_send(cli->tree, &io); if (req == NULL) { printf("Failed to setup timed lock (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -554,7 +555,7 @@ static bool test_async(struct torture_context *tctx, if (time(NULL) > t+2) { printf("lock cancel by unlock was not immediate (%s) - took %d secs\n", __location__, (int)(time(NULL)-t)); - ret = False; + ret = false; goto done; } @@ -571,7 +572,7 @@ static bool test_async(struct torture_context *tctx, req = smb_raw_lock_send(cli->tree, &io); if (req == NULL) { printf("Failed to setup timed lock (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -583,24 +584,24 @@ static bool test_async(struct torture_context *tctx, if (time(NULL) > t+2) { printf("lock cancel by close was not immediate (%s)\n", __location__); - ret = False; + ret = false; goto done; } printf("create a new sessions\n"); - session = smbcli_session_init(cli->transport, tctx, False); + session = smbcli_session_init(cli->transport, tctx, false); setup.in.sesskey = cli->transport->negotiate.sesskey; setup.in.capabilities = cli->transport->negotiate.capabilities; - setup.in.workgroup = lp_workgroup(); + setup.in.workgroup = lp_workgroup(global_loadparm); setup.in.credentials = cmdline_credentials; status = smb_composite_sesssetup(session, &setup); CHECK_STATUS(status, NT_STATUS_OK); session->vuid = setup.out.vuid; printf("create new tree context\n"); - share = lp_parm_string(-1, "torture", "share"); - host = lp_parm_string(-1, "torture", "host"); - tree = smbcli_tree_init(session, tctx, False); + share = lp_parm_string(global_loadparm, NULL, "torture", "share"); + host = lp_parm_string(global_loadparm, NULL, "torture", "host"); + tree = smbcli_tree_init(session, tctx, false); tcon.generic.level = RAW_TCON_TCONX; tcon.tconx.in.flags = 0; tcon.tconx.in.password = data_blob(NULL, 0); @@ -615,7 +616,7 @@ static bool test_async(struct torture_context *tctx, fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree)); - ret = False; + ret = false; goto done; } io.lockx.level = RAW_LOCK_LOCKX; @@ -643,7 +644,7 @@ static bool test_async(struct torture_context *tctx, req = smb_raw_lock_send(tree, &io); if (req == NULL) { printf("Failed to setup timed lock (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -655,7 +656,7 @@ static bool test_async(struct torture_context *tctx, if (time(NULL) > t+2) { printf("lock cancel by exit was not immediate (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -664,7 +665,7 @@ static bool test_async(struct torture_context *tctx, fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree)); - ret = False; + ret = false; goto done; } io.lockx.level = RAW_LOCK_LOCKX; @@ -692,7 +693,7 @@ static bool test_async(struct torture_context *tctx, req = smb_raw_lock_send(tree, &io); if (req == NULL) { printf("Failed to setup timed lock (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -711,7 +712,7 @@ static bool test_async(struct torture_context *tctx, if (time(NULL) > t+2) { printf("lock cancel by ulogoff was not immediate (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -722,7 +723,7 @@ static bool test_async(struct torture_context *tctx, fnum = smbcli_open(tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(tree)); - ret = False; + ret = false; goto done; } io.lockx.level = RAW_LOCK_LOCKX; @@ -746,7 +747,7 @@ static bool test_async(struct torture_context *tctx, req = smb_raw_lock_send(tree, &io); if (req == NULL) { printf("Failed to setup timed lock (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -758,7 +759,7 @@ static bool test_async(struct torture_context *tctx, if (time(NULL) > t+2) { printf("lock cancel by tdis was not immediate (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -778,7 +779,7 @@ static bool test_errorcode(struct torture_context *tctx, union smb_open op; struct smb_lock_entry lock[2]; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum, fnum2; const char *fname; struct smbcli_request *req; @@ -786,7 +787,7 @@ static bool test_errorcode(struct torture_context *tctx, int t; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing LOCK_NOT_GRANTED vs. FILE_LOCK_CONFLICT\n"); @@ -1104,7 +1105,7 @@ next_run: fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } io.lockx.level = RAW_LOCK_LOCKX; @@ -1125,7 +1126,7 @@ next_run: req = smb_raw_lock_send(cli->tree, &io); if (req == NULL) { printf("Failed to setup timed lock (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -1143,7 +1144,7 @@ next_run: if (time(NULL) < start+1) { printf("lock comes back to early (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -1152,7 +1153,7 @@ next_run: fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } io.lockx.level = RAW_LOCK_LOCKX; @@ -1173,7 +1174,7 @@ next_run: req = smb_raw_lock_send(cli->tree, &io); if (req == NULL) { printf("Failed to setup timed lock (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -1193,7 +1194,7 @@ next_run: if (time(NULL) < start+1) { printf("lock comes back to early (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -1202,7 +1203,7 @@ next_run: fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to reopen %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } io.lockx.level = RAW_LOCK_LOCKX; @@ -1223,7 +1224,7 @@ next_run: req = smb_raw_lock_send(cli->tree, &io); if (req == NULL) { printf("Failed to setup timed lock (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -1239,7 +1240,7 @@ next_run: if (time(NULL) < start+1) { printf("lock comes back to early (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -1259,13 +1260,13 @@ static bool test_changetype(struct torture_context *tctx, union smb_lock io; struct smb_lock_entry lock[2]; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; uint8_t c = 0; const char *fname = BASEDIR "\\test.txt"; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing LOCKING_ANDX_CHANGE_LOCKTYPE\n"); @@ -1274,7 +1275,7 @@ static bool test_changetype(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -1293,7 +1294,7 @@ static bool test_changetype(struct torture_context *tctx, if (smbcli_write(cli->tree, fnum, 0, &c, 100, 1) == 1) { printf("allowed write on read locked region (%s)\n", __location__); - ret = False; + ret = false; goto done; } @@ -1304,7 +1305,7 @@ static bool test_changetype(struct torture_context *tctx, if (smbcli_write(cli->tree, fnum, 0, &c, 100, 1) == 1) { printf("allowed write after lock change (%s)\n", __location__); - ret = False; + ret = false; goto done; } diff --git a/source4/torture/raw/lockbench.c b/source4/torture/raw/lockbench.c index 44b60b8695..855364b169 100644 --- a/source4/torture/raw/lockbench.c +++ b/source4/torture/raw/lockbench.c @@ -30,6 +30,7 @@ #include "lib/cmdline/popt_common.h" #include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" +#include "param/param.h" #define BASEDIR "\\benchlock" #define FNAME BASEDIR "\\lock.dat" @@ -188,8 +189,8 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te, io->in.service = share; io->in.service_type = state->service_type; io->in.credentials = cmdline_credentials; - io->in.fallback_to_anonymous = False; - io->in.workgroup = lp_workgroup(); + io->in.fallback_to_anonymous = false; + io->in.workgroup = lp_workgroup(global_loadparm); /* kill off the remnants of the old connection */ talloc_free(state->tree); @@ -302,9 +303,9 @@ static void report_rate(struct event_context *ev, struct timed_event *te, /* benchmark locking calls */ -BOOL torture_bench_lock(struct torture_context *torture) +bool torture_bench_lock(struct torture_context *torture) { - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx = talloc_new(torture); int i; int timelimit = torture_setting_int(torture, "timelimit", 10); @@ -317,7 +318,7 @@ BOOL torture_bench_lock(struct torture_context *torture) progress = torture_setting_bool(torture, "progress", true); - nprocs = lp_parm_int(-1, "torture", "nprocs", 4); + nprocs = lp_parm_int(global_loadparm, NULL, "torture", "nprocs", 4); state = talloc_zero_array(mem_ctx, struct benchlock_state, nprocs); @@ -327,7 +328,7 @@ BOOL torture_bench_lock(struct torture_context *torture) state[i].client_num = i; state[i].ev = ev; if (!torture_open_connection_ev(&cli, i, ev)) { - return False; + return false; } talloc_steal(mem_ctx, state); state[i].tree = cli->tree; diff --git a/source4/torture/raw/mkdir.c b/source4/torture/raw/mkdir.c index 0e2fd1afe0..f502b10a69 100644 --- a/source4/torture/raw/mkdir.c +++ b/source4/torture/raw/mkdir.c @@ -22,6 +22,7 @@ #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" #include "torture/util.h" +#include "param/param.h" #define BASEDIR "\\mkdirtest" @@ -29,23 +30,23 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) /* test mkdir ops */ -static BOOL test_mkdir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_mkdir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_mkdir md; struct smb_rmdir rd; const char *path = BASEDIR "\\mkdir.dir"; NTSTATUS status; - BOOL ret = True; + bool ret = true; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } /* @@ -129,7 +130,7 @@ static BOOL test_mkdir(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) md.t2mkdir.in.eas[2].value = data_blob_talloc(mem_ctx, "xx1", 3); status = smb_raw_mkdir(cli->tree, &md); - if (lp_parm_bool(-1, "torture", "samba3", False) + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false) && NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED)) { d_printf("EAS not supported -- not treating as fatal\n"); } @@ -160,8 +161,8 @@ done: /* basic testing of all RAW_MKDIR_* calls */ -BOOL torture_raw_mkdir(struct torture_context *torture, - struct smbcli_state *cli) +bool torture_raw_mkdir(struct torture_context *torture, + struct smbcli_state *cli) { bool ret = true; diff --git a/source4/torture/raw/mux.c b/source4/torture/raw/mux.c index b67d756ed9..846a9787cb 100644 --- a/source4/torture/raw/mux.c +++ b/source4/torture/raw/mux.c @@ -30,7 +30,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -38,12 +38,12 @@ /* test the delayed reply to a open that leads to a sharing violation */ -static BOOL test_mux_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_mux_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; NTSTATUS status; int fnum1, fnum2; - BOOL ret = True; + bool ret = true; struct smbcli_request *req1, *req2; struct timeval tv; double d; @@ -104,7 +104,7 @@ static BOOL test_mux_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) d = timeval_elapsed(&tv); if (d > 0.25) { printf("bad timeout after cancel - %.2f should be <0.25\n", d); - ret = False; + ret = false; } printf("close the 2nd sync open\n"); @@ -117,7 +117,7 @@ static BOOL test_mux_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) d = timeval_elapsed(&tv); if (d > 0.25) { printf("bad timeout for async conflict - %.2f should be <0.25\n", d); - ret = False; + ret = false; } else { printf("async open delay %.2f\n", d); } @@ -141,12 +141,12 @@ done: /* test a write that hits a byte range lock and send the close after the write */ -static BOOL test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_write io; NTSTATUS status; int fnum; - BOOL ret = True; + bool ret = true; struct smbcli_request *req; printf("testing multiplexed lock/write/close\n"); @@ -154,7 +154,7 @@ static BOOL test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) fnum = smbcli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE); if (fnum == -1) { printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -163,7 +163,7 @@ static BOOL test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* lock a range */ if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 0, 4, 0, WRITE_LOCK))) { printf("lock failed in mux_write - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -176,7 +176,7 @@ static BOOL test_mux_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io.writex.in.wmode = 0; io.writex.in.remaining = 0; io.writex.in.count = 4; - io.writex.in.data = (void *)&fnum; + io.writex.in.data = (const uint8_t *)&fnum; req = smb_raw_write_send(cli->tree, &io); /* unlock the range */ @@ -197,12 +197,12 @@ done: /* test a lock that conflicts with an existing lock */ -static BOOL test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_lock io; NTSTATUS status; int fnum; - BOOL ret = True; + bool ret = true; struct smbcli_request *req; struct smb_lock_entry lock[1]; struct timeval t; @@ -212,7 +212,7 @@ static BOOL test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) fnum = smbcli_open(cli->tree, BASEDIR "\\write.dat", O_RDWR | O_CREAT, DENY_NONE); if (fnum == -1) { printf("open failed in mux_write - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -256,7 +256,7 @@ static BOOL test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("async lock took %.2f msec\n", timeval_elapsed(&t) * 1000); if (timeval_elapsed(&t) > 0.1) { printf("failed to trigger early lock retry\n"); - return False; + return false; } printf("reopening with an exit\n"); @@ -330,7 +330,7 @@ static BOOL test_mux_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("async lock exit took %.2f msec\n", timeval_elapsed(&t) * 1000); if (timeval_elapsed(&t) > 0.1) { printf("failed to trigger early lock failure\n"); - return False; + return false; } done: diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c index 1540a4a2dd..96c7e4f947 100644 --- a/source4/torture/raw/notify.c +++ b/source4/torture/raw/notify.c @@ -23,6 +23,7 @@ #include "libcli/libcli.h" #include "system/filesys.h" #include "torture/util.h" +#include "param/param.h" #define BASEDIR "\\test_notify" @@ -30,7 +31,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%d) Incorrect status %s - should be %s\n", \ __LINE__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -39,14 +40,14 @@ if ((v) != (correct)) { \ printf("(%d) wrong value for %s 0x%x should be 0x%x\n", \ __LINE__, #v, (int)v, (int)correct); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) #define CHECK_WSTR(field, value, flags) do { \ if (!field.s || strcmp(field.s, value) || wire_bad_flags(&field, flags, cli->transport)) { \ printf("(%d) %s [%s] != %s\n", __LINE__, #field, field.s, value); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -54,10 +55,10 @@ /* basic testing of change notify on directories */ -static BOOL test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2, +static bool test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2, TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; @@ -98,7 +99,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2, notify.nttrans.in.buffer_size = 1000; notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; notify.nttrans.in.file.fnum = fnum; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; printf("testing notify cancel\n"); @@ -158,7 +159,7 @@ static BOOL test_notify_dir(struct smbcli_state *cli, struct smbcli_state *cli2, if (fnum3 == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } talloc_free(fname); @@ -266,7 +267,7 @@ done: * pair in any of the three following notify_changes. */ -static BOOL check_rename_reply(struct smbcli_state *cli, +static bool check_rename_reply(struct smbcli_state *cli, int line, struct notify_changes *actions, uint32_t action, const char *name) @@ -281,22 +282,22 @@ static BOOL check_rename_reply(struct smbcli_state *cli, cli->transport))) { printf("(%d) name [%s] != %s\n", line, actions[i].name.s, name); - return False; + return false; } - return True; + return true; } } printf("(%d) expected action %d, not found\n", line, action); - return False; + return false; } /* testing of recursive change notify */ -static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; @@ -332,10 +333,10 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_CREATION; notify.nttrans.in.file.fnum = fnum; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; req1 = smb_raw_changenotify_send(cli->tree, ¬ify); - notify.nttrans.in.recursive = False; + notify.nttrans.in.recursive = false; req2 = smb_raw_changenotify_send(cli->tree, ¬ify); /* cancel initial requests so the buffer is setup */ @@ -356,7 +357,7 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) smbcli_rename(cli->tree, BASEDIR "\\subname2-r", BASEDIR "\\subname3-r"); notify.nttrans.in.completion_filter = 0; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; msleep(200); req1 = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -364,7 +365,7 @@ static BOOL test_notify_recursive(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) smbcli_rmdir(cli->tree, BASEDIR "\\subdir-name"); smbcli_unlink(cli->tree, BASEDIR "\\subname3-r"); - notify.nttrans.in.recursive = False; + notify.nttrans.in.recursive = false; req2 = smb_raw_changenotify_send(cli->tree, ¬ify); status = smb_raw_changenotify_recv(req1, mem_ctx, ¬ify); @@ -425,15 +426,14 @@ done: /* testing of change notify mask change */ -static BOOL test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; int fnum; struct smbcli_request *req1, *req2; - union smb_setfileinfo sfinfo; printf("TESTING CHANGE NOTIFY WITH MASK CHANGE\n"); @@ -464,10 +464,10 @@ static BOOL test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ct notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_ATTRIBUTES; notify.nttrans.in.file.fnum = fnum; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; req1 = smb_raw_changenotify_send(cli->tree, ¬ify); - notify.nttrans.in.recursive = False; + notify.nttrans.in.recursive = false; req2 = smb_raw_changenotify_send(cli->tree, ¬ify); /* cancel initial requests so the buffer is setup */ @@ -479,7 +479,7 @@ static BOOL test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ct status = smb_raw_changenotify_recv(req2, mem_ctx, ¬ify); CHECK_STATUS(status, NT_STATUS_CANCELLED); - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; req1 = smb_raw_changenotify_send(cli->tree, ¬ify); /* Set to hidden then back again. */ @@ -499,10 +499,10 @@ static BOOL test_notify_mask_change(struct smbcli_state *cli, TALLOC_CTX *mem_ct * fnum it seems to be fixed until the fnum is closed. */ notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_CREATION; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; req1 = smb_raw_changenotify_send(cli->tree, ¬ify); - notify.nttrans.in.recursive = False; + notify.nttrans.in.recursive = false; req2 = smb_raw_changenotify_send(cli->tree, ¬ify); smbcli_mkdir(cli->tree, BASEDIR "\\subdir-name"); @@ -544,9 +544,9 @@ done: /* testing of mask bits for change notify */ -static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; @@ -580,7 +580,7 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) notify.nttrans.level = RAW_NOTIFY_NTTRANS; notify.nttrans.in.buffer_size = 1000; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; #define NOTIFY_MASK_TEST(setup, op, cleanup, Action, expected, nchanges) \ do { for (mask=i=0;i<32;i++) { \ @@ -611,21 +611,21 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) nchanges, \ notify.nttrans.out.changes[0].action, \ notify.nttrans.in.completion_filter); \ - ret = False; \ + ret = false; \ } else if (notify.nttrans.out.changes[0].action != Action) { \ printf("ERROR: nchanges=%d action=%d expectedAction=%d filter=0x%08x\n", \ notify.nttrans.out.num_changes, \ notify.nttrans.out.changes[0].action, \ Action, \ notify.nttrans.in.completion_filter); \ - ret = False; \ + ret = false; \ } else if (strcmp(notify.nttrans.out.changes[0].name.s, "tname1") != 0) { \ printf("ERROR: nchanges=%d action=%d filter=0x%08x name=%s\n", \ notify.nttrans.out.num_changes, \ notify.nttrans.out.changes[0].action, \ notify.nttrans.in.completion_filter, \ notify.nttrans.out.changes[0].name.s); \ - ret = False; \ + ret = false; \ } \ mask |= (1<<i); \ } \ @@ -633,7 +633,7 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (((expected) & ~mask) != 0) { \ printf("ERROR: trigger on too few bits. mask=0x%08x expected=0x%08x\n", \ mask, expected); \ - ret = False; \ + ret = false; \ } else { \ printf("WARNING: trigger on too many bits. mask=0x%08x expected=0x%08x\n", \ mask, expected); \ @@ -711,7 +711,7 @@ static BOOL test_notify_mask(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) NOTIFY_ACTION_MODIFIED, FILE_NOTIFY_CHANGE_ATTRIBUTES, 1); - if (lp_parm_bool(-1, "torture", "samba3", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { printf("Samba3 does not yet support create times " "everywhere\n"); } @@ -776,10 +776,10 @@ done: /* basic testing of change notify on files */ -static BOOL test_notify_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_notify_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; - BOOL ret = True; + bool ret = true; union smb_open io; union smb_close cl; union smb_notify notify; @@ -811,7 +811,7 @@ static BOOL test_notify_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) notify.nttrans.in.file.fnum = fnum; notify.nttrans.in.buffer_size = 1000; notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_STREAM_NAME; - notify.nttrans.in.recursive = False; + notify.nttrans.in.recursive = false; printf("testing if notifies on file handles are invalid (should be)\n"); @@ -836,9 +836,9 @@ done: /* basic testing of change notifies followed by a tdis */ -static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx) +static bool test_notify_tdis(TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; @@ -849,7 +849,7 @@ static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx) printf("TESTING CHANGE NOTIFY FOLLOWED BY TDIS\n"); if (!torture_open_connection(&cli, 0)) { - return False; + return false; } /* @@ -878,7 +878,7 @@ static BOOL test_notify_tdis(TALLOC_CTX *mem_ctx) notify.nttrans.in.buffer_size = 1000; notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; notify.nttrans.in.file.fnum = fnum; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; req = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -898,9 +898,9 @@ done: /* basic testing of change notifies followed by a exit */ -static BOOL test_notify_exit(TALLOC_CTX *mem_ctx) +static bool test_notify_exit(TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; @@ -911,7 +911,7 @@ static BOOL test_notify_exit(TALLOC_CTX *mem_ctx) printf("TESTING CHANGE NOTIFY FOLLOWED BY EXIT\n"); if (!torture_open_connection(&cli, 0)) { - return False; + return false; } /* @@ -940,7 +940,7 @@ static BOOL test_notify_exit(TALLOC_CTX *mem_ctx) notify.nttrans.in.buffer_size = 1000; notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; notify.nttrans.in.file.fnum = fnum; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; req = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -959,9 +959,9 @@ done: /* basic testing of change notifies followed by a ulogoff */ -static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx) +static bool test_notify_ulogoff(TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; @@ -972,7 +972,7 @@ static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx) printf("TESTING CHANGE NOTIFY FOLLOWED BY ULOGOFF\n"); if (!torture_open_connection(&cli, 0)) { - return False; + return false; } /* @@ -1001,7 +1001,7 @@ static BOOL test_notify_ulogoff(TALLOC_CTX *mem_ctx) notify.nttrans.in.buffer_size = 1000; notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; notify.nttrans.in.file.fnum = fnum; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; req = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -1019,7 +1019,7 @@ done: static void tcp_dis_handler(struct smbcli_transport *t, void *p) { - struct smbcli_state *cli = p; + struct smbcli_state *cli = (struct smbcli_state *)p; smbcli_transport_dead(cli->transport, NT_STATUS_LOCAL_DISCONNECT); cli->transport = NULL; cli->tree = NULL; @@ -1027,9 +1027,9 @@ static void tcp_dis_handler(struct smbcli_transport *t, void *p) /* basic testing of change notifies followed by tcp disconnect */ -static BOOL test_notify_tcp_dis(TALLOC_CTX *mem_ctx) +static bool test_notify_tcp_dis(TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; @@ -1040,7 +1040,7 @@ static BOOL test_notify_tcp_dis(TALLOC_CTX *mem_ctx) printf("TESTING CHANGE NOTIFY FOLLOWED BY TCP DISCONNECT\n"); if (!torture_open_connection(&cli, 0)) { - return False; + return false; } /* @@ -1069,7 +1069,7 @@ static BOOL test_notify_tcp_dis(TALLOC_CTX *mem_ctx) notify.nttrans.in.buffer_size = 1000; notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; notify.nttrans.in.file.fnum = fnum; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; req = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -1086,9 +1086,9 @@ done: /* test setting up two change notify requests on one handle */ -static BOOL test_notify_double(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_notify_double(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_notify notify; union smb_open io; @@ -1123,7 +1123,7 @@ static BOOL test_notify_double(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) notify.nttrans.in.buffer_size = 1000; notify.nttrans.in.completion_filter = FILE_NOTIFY_CHANGE_NAME; notify.nttrans.in.file.fnum = fnum; - notify.nttrans.in.recursive = True; + notify.nttrans.in.recursive = true; req1 = smb_raw_changenotify_send(cli->tree, ¬ify); req2 = smb_raw_changenotify_send(cli->tree, ¬ify); @@ -1151,45 +1151,45 @@ done: /* test multiple change notifies at different depths and with/without recursion */ -static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; union smb_notify notify; union smb_open io; struct smbcli_request *req; struct timeval tv; struct { const char *path; - BOOL recursive; + bool recursive; uint32_t filter; int expected; int fnum; int counted; } dirs[] = { - {BASEDIR "\\abc", True, FILE_NOTIFY_CHANGE_NAME, 30 }, - {BASEDIR "\\zqy", True, FILE_NOTIFY_CHANGE_NAME, 8 }, - {BASEDIR "\\atsy", True, FILE_NOTIFY_CHANGE_NAME, 4 }, - {BASEDIR "\\abc\\foo", True, FILE_NOTIFY_CHANGE_NAME, 2 }, - {BASEDIR "\\abc\\blah", True, FILE_NOTIFY_CHANGE_NAME, 13 }, - {BASEDIR "\\abc\\blah", False, FILE_NOTIFY_CHANGE_NAME, 7 }, - {BASEDIR "\\abc\\blah\\a", True, FILE_NOTIFY_CHANGE_NAME, 2 }, - {BASEDIR "\\abc\\blah\\b", True, FILE_NOTIFY_CHANGE_NAME, 2 }, - {BASEDIR "\\abc\\blah\\c", True, FILE_NOTIFY_CHANGE_NAME, 2 }, - {BASEDIR "\\abc\\fooblah", True, FILE_NOTIFY_CHANGE_NAME, 2 }, - {BASEDIR "\\zqy\\xx", True, FILE_NOTIFY_CHANGE_NAME, 2 }, - {BASEDIR "\\zqy\\yyy", True, FILE_NOTIFY_CHANGE_NAME, 2 }, - {BASEDIR "\\zqy\\..", True, FILE_NOTIFY_CHANGE_NAME, 40 }, - {BASEDIR, True, FILE_NOTIFY_CHANGE_NAME, 40 }, - {BASEDIR, False,FILE_NOTIFY_CHANGE_NAME, 6 }, - {BASEDIR "\\atsy", False,FILE_NOTIFY_CHANGE_NAME, 4 }, - {BASEDIR "\\abc", True, FILE_NOTIFY_CHANGE_NAME, 24 }, - {BASEDIR "\\abc", False,FILE_NOTIFY_CHANGE_FILE_NAME, 0 }, - {BASEDIR "\\abc", True, FILE_NOTIFY_CHANGE_FILE_NAME, 0 }, - {BASEDIR "\\abc", True, FILE_NOTIFY_CHANGE_NAME, 24 }, + {BASEDIR "\\abc", true, FILE_NOTIFY_CHANGE_NAME, 30 }, + {BASEDIR "\\zqy", true, FILE_NOTIFY_CHANGE_NAME, 8 }, + {BASEDIR "\\atsy", true, FILE_NOTIFY_CHANGE_NAME, 4 }, + {BASEDIR "\\abc\\foo", true, FILE_NOTIFY_CHANGE_NAME, 2 }, + {BASEDIR "\\abc\\blah", true, FILE_NOTIFY_CHANGE_NAME, 13 }, + {BASEDIR "\\abc\\blah", false, FILE_NOTIFY_CHANGE_NAME, 7 }, + {BASEDIR "\\abc\\blah\\a", true, FILE_NOTIFY_CHANGE_NAME, 2 }, + {BASEDIR "\\abc\\blah\\b", true, FILE_NOTIFY_CHANGE_NAME, 2 }, + {BASEDIR "\\abc\\blah\\c", true, FILE_NOTIFY_CHANGE_NAME, 2 }, + {BASEDIR "\\abc\\fooblah", true, FILE_NOTIFY_CHANGE_NAME, 2 }, + {BASEDIR "\\zqy\\xx", true, FILE_NOTIFY_CHANGE_NAME, 2 }, + {BASEDIR "\\zqy\\yyy", true, FILE_NOTIFY_CHANGE_NAME, 2 }, + {BASEDIR "\\zqy\\..", true, FILE_NOTIFY_CHANGE_NAME, 40 }, + {BASEDIR, true, FILE_NOTIFY_CHANGE_NAME, 40 }, + {BASEDIR, false,FILE_NOTIFY_CHANGE_NAME, 6 }, + {BASEDIR "\\atsy", false,FILE_NOTIFY_CHANGE_NAME, 4 }, + {BASEDIR "\\abc", true, FILE_NOTIFY_CHANGE_NAME, 24 }, + {BASEDIR "\\abc", false,FILE_NOTIFY_CHANGE_FILE_NAME, 0 }, + {BASEDIR "\\abc", true, FILE_NOTIFY_CHANGE_FILE_NAME, 0 }, + {BASEDIR "\\abc", true, FILE_NOTIFY_CHANGE_NAME, 24 }, }; int i; NTSTATUS status; - BOOL all_done = False; + bool all_done = false; printf("TESTING CHANGE NOTIFY FOR DIFFERENT DEPTHS\n"); @@ -1248,11 +1248,11 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) dirs[i].counted += notify.nttrans.out.num_changes; } - all_done = True; + all_done = true; for (i=0;i<ARRAY_SIZE(dirs);i++) { if (dirs[i].counted != dirs[i].expected) { - all_done = False; + all_done = false; } } } while (!all_done && timeval_elapsed(&tv) < 20); @@ -1263,7 +1263,7 @@ static BOOL test_notify_tree(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (dirs[i].counted != dirs[i].expected) { printf("ERROR: i=%d expected %d got %d for '%s'\n", i, dirs[i].expected, dirs[i].counted, dirs[i].path); - ret = False; + ret = false; } } @@ -1284,8 +1284,8 @@ done: basic testing of change notify */ bool torture_raw_notify(struct torture_context *torture, - struct smbcli_state *cli, - struct smbcli_state *cli2) + struct smbcli_state *cli, + struct smbcli_state *cli2) { bool ret = true; diff --git a/source4/torture/raw/open.c b/source4/torture/raw/open.c index f8fa4ff8fe..c4ccc0eb17 100644 --- a/source4/torture/raw/open.c +++ b/source4/torture/raw/open.c @@ -28,6 +28,7 @@ #include "torture/util.h" #include "auth/credentials/credentials.h" #include "lib/cmdline/popt_common.h" +#include "param/param.h" /* enum for whether reads/writes are possible on a file */ enum rdwr_mode {RDWR_NONE, RDWR_RDONLY, RDWR_WRONLY, RDWR_RDWR}; @@ -40,8 +41,8 @@ enum rdwr_mode {RDWR_NONE, RDWR_RDONLY, RDWR_WRONLY, RDWR_RDWR}; static enum rdwr_mode check_rdwr(struct smbcli_tree *tree, int fnum) { uint8_t c = 1; - BOOL can_read = (smbcli_read(tree, fnum, &c, 0, 1) == 1); - BOOL can_write = (smbcli_write(tree, fnum, 0, &c, 0, 1) == 1); + bool can_read = (smbcli_read(tree, fnum, &c, 0, 1) == 1); + bool can_write = (smbcli_write(tree, fnum, 0, &c, 0, 1) == 1); if ( can_read && can_write) return RDWR_RDWR; if ( can_read && !can_write) return RDWR_RDONLY; if (!can_read && can_write) return RDWR_WRONLY; @@ -66,7 +67,7 @@ static const char *rdwr_string(enum rdwr_mode m) if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -74,7 +75,7 @@ static const char *rdwr_string(enum rdwr_mode m) fnum = create_complex_file(cli, mem_ctx, fname); \ if (fnum == -1) { \ printf("(%s) Failed to create %s - %s\n", __location__, fname, smbcli_errstr(cli->tree)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -83,7 +84,7 @@ static const char *rdwr_string(enum rdwr_mode m) if (m != correct) { \ printf("(%s) Incorrect readwrite mode %s - expected %s\n", \ __location__, rdwr_string(m), rdwr_string(correct)); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_TIME(t, field) do { \ @@ -100,7 +101,7 @@ static const char *rdwr_string(enum rdwr_mode m) timestring(mem_ctx, t1), \ timestring(mem_ctx, t2)); \ dump_all_info(mem_ctx, &finfo); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_NTTIME(t, field) do { \ @@ -116,7 +117,7 @@ static const char *rdwr_string(enum rdwr_mode m) nt_time_string(mem_ctx, t), \ nt_time_string(mem_ctx, t2)); \ dump_all_info(mem_ctx, &finfo); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_ALL_INFO(v, field) do { \ @@ -128,14 +129,14 @@ static const char *rdwr_string(enum rdwr_mode m) printf("(%s) wrong value for field %s 0x%x - 0x%x\n", \ __location__, #field, (int)v, (int)(finfo.all_info.out.field)); \ dump_all_info(mem_ctx, &finfo); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_VAL(v, correct) do { \ if ((v) != (correct)) { \ printf("(%s) wrong value for %s 0x%x - should be 0x%x\n", \ __location__, #v, (int)(v), (int)correct); \ - ret = False; \ + ret = false; \ }} while (0) #define SET_ATTRIB(sattrib) do { \ @@ -153,14 +154,14 @@ static const char *rdwr_string(enum rdwr_mode m) /* test RAW_OPEN_OPEN */ -static BOOL test_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; union smb_fileinfo finfo; const char *fname = BASEDIR "\\torture_open.txt"; NTSTATUS status; int fnum = -1, fnum2; - BOOL ret = True; + bool ret = true; printf("Checking RAW_OPEN_OPEN\n"); @@ -264,7 +265,7 @@ done: /* test RAW_OPEN_OPENX */ -static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; union smb_fileinfo finfo; @@ -272,26 +273,26 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *fname_exe = BASEDIR "\\torture_openx.exe"; NTSTATUS status; int fnum = -1, fnum2; - BOOL ret = True; + bool ret = true; int i; struct timeval tv; struct { uint16_t open_func; - BOOL with_file; + bool with_file; NTSTATUS correct_status; } open_funcs[] = { - { OPENX_OPEN_FUNC_OPEN, True, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_OPEN, False, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_FAIL, True, NT_STATUS_DOS(ERRDOS, ERRbadaccess) }, - { OPENX_OPEN_FUNC_FAIL, False, NT_STATUS_DOS(ERRDOS, ERRbadaccess) }, - { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OBJECT_NAME_COLLISION }, - { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_TRUNC, True, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_TRUNC, False, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_OPEN, true, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_FAIL, true, NT_STATUS_DOS(ERRDOS, ERRbadaccess) }, + { OPENX_OPEN_FUNC_FAIL, false, NT_STATUS_DOS(ERRDOS, ERRbadaccess) }, + { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION }, + { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_TRUNC, true, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_TRUNC, false, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK }, }; printf("Checking RAW_OPEN_OPENX\n"); @@ -313,7 +314,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) fnum = create_complex_file(cli, mem_ctx, fname); if (fnum == -1) { d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } smbcli_close(cli->tree, fnum); @@ -324,7 +325,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_func=0x%x)\n", __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status), i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_func); - ret = False; + ret = false; } if (NT_STATUS_IS_OK(status)) { smbcli_close(cli->tree, io.openx.out.file.fnum); @@ -357,7 +358,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) /* check the fields when the file already existed */ fnum2 = create_complex_file(cli, mem_ctx, fname); if (fnum2 == -1) { - ret = False; + ret = false; goto done; } smbcli_close(cli->tree, fnum2); @@ -397,7 +398,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) io.openx.in.file_attrs = FILE_ATTRIBUTE_SYSTEM; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); - if (lp_parm_bool(-1, "torture", "samba3", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { CHECK_ALL_INFO(FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE, attrib & ~(FILE_ATTRIBUTE_NONINDEXED| FILE_ATTRIBUTE_SPARSE)); @@ -425,7 +426,7 @@ static BOOL test_openx(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (timeval_elapsed(&tv) > 3.0) { printf("(%s) Incorrect timing in openx with timeout - waited %.2f seconds\n", __location__, timeval_elapsed(&tv)); - ret = False; + ret = false; } smbcli_close(cli->tree, fnum); smbcli_unlink(cli->tree, fname); @@ -494,7 +495,7 @@ done: many thanks to kukks for a sniff showing how this works with os2->w2k */ -static BOOL test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; union smb_fileinfo finfo; @@ -503,31 +504,31 @@ static BOOL test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *fname = BASEDIR "\\torture_t2open_3.txt"; NTSTATUS status; int fnum; - BOOL ret = True; + bool ret = true; int i; struct { uint16_t open_func; - BOOL with_file; + bool with_file; NTSTATUS correct_status; } open_funcs[] = { - { OPENX_OPEN_FUNC_OPEN, True, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_OPEN, False, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_FAIL, True, NT_STATUS_OBJECT_NAME_COLLISION }, - { OPENX_OPEN_FUNC_FAIL, False, NT_STATUS_OBJECT_NAME_COLLISION }, - { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OBJECT_NAME_COLLISION }, - { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OBJECT_NAME_COLLISION }, - { OPENX_OPEN_FUNC_TRUNC, True, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_TRUNC, False, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, True, NT_STATUS_OK }, - { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, False, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_OPEN, true, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_OPEN | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_FAIL, true, NT_STATUS_OBJECT_NAME_COLLISION }, + { OPENX_OPEN_FUNC_FAIL, false, NT_STATUS_OBJECT_NAME_COLLISION }, + { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION }, + { OPENX_OPEN_FUNC_FAIL | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OBJECT_NAME_COLLISION }, + { OPENX_OPEN_FUNC_TRUNC, true, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_TRUNC, false, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, true, NT_STATUS_OK }, + { OPENX_OPEN_FUNC_TRUNC | OPENX_OPEN_FUNC_CREATE, false, NT_STATUS_OK }, }; fnum = create_complex_file(cli, mem_ctx, fname1); if (fnum == -1) { d_printf("Failed to create file %s - %s\n", fname1, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } smbcli_close(cli->tree, fnum); @@ -568,7 +569,7 @@ static BOOL test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) status = smb_raw_open(cli->tree, mem_ctx, &io); if ((io.t2open.in.num_eas != 0) && NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED) - && lp_parm_bool(-1, "torture", "samba3", False)) { + && lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { printf("(%s) EAs not supported, not treating as fatal " "in Samba3 test\n", __location__); io.t2open.in.num_eas = 0; @@ -579,7 +580,7 @@ static BOOL test_t2open(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_func=0x%x)\n", __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status), i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_func); - ret = False; + ret = false; } if (NT_STATUS_IS_OK(status)) { smbcli_close(cli->tree, io.t2open.out.file.fnum); @@ -659,7 +660,7 @@ done: /* test RAW_OPEN_NTCREATEX */ -static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; union smb_fileinfo finfo; @@ -667,27 +668,27 @@ static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *dname = BASEDIR "\\torture_ntcreatex.dir"; NTSTATUS status; int fnum = -1; - BOOL ret = True; + bool ret = true; int i; struct { uint32_t open_disp; - BOOL with_file; + bool with_file; NTSTATUS correct_status; } open_funcs[] = { - { NTCREATEX_DISP_SUPERSEDE, True, NT_STATUS_OK }, - { NTCREATEX_DISP_SUPERSEDE, False, NT_STATUS_OK }, - { NTCREATEX_DISP_OPEN, True, NT_STATUS_OK }, - { NTCREATEX_DISP_OPEN, False, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { NTCREATEX_DISP_CREATE, True, NT_STATUS_OBJECT_NAME_COLLISION }, - { NTCREATEX_DISP_CREATE, False, NT_STATUS_OK }, - { NTCREATEX_DISP_OPEN_IF, True, NT_STATUS_OK }, - { NTCREATEX_DISP_OPEN_IF, False, NT_STATUS_OK }, - { NTCREATEX_DISP_OVERWRITE, True, NT_STATUS_OK }, - { NTCREATEX_DISP_OVERWRITE, False, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { NTCREATEX_DISP_OVERWRITE_IF, True, NT_STATUS_OK }, - { NTCREATEX_DISP_OVERWRITE_IF, False, NT_STATUS_OK }, - { 6, True, NT_STATUS_INVALID_PARAMETER }, - { 6, False, NT_STATUS_INVALID_PARAMETER }, + { NTCREATEX_DISP_SUPERSEDE, true, NT_STATUS_OK }, + { NTCREATEX_DISP_SUPERSEDE, false, NT_STATUS_OK }, + { NTCREATEX_DISP_OPEN, true, NT_STATUS_OK }, + { NTCREATEX_DISP_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { NTCREATEX_DISP_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION }, + { NTCREATEX_DISP_CREATE, false, NT_STATUS_OK }, + { NTCREATEX_DISP_OPEN_IF, true, NT_STATUS_OK }, + { NTCREATEX_DISP_OPEN_IF, false, NT_STATUS_OK }, + { NTCREATEX_DISP_OVERWRITE, true, NT_STATUS_OK }, + { NTCREATEX_DISP_OVERWRITE, false, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { NTCREATEX_DISP_OVERWRITE_IF, true, NT_STATUS_OK }, + { NTCREATEX_DISP_OVERWRITE_IF, false, NT_STATUS_OK }, + { 6, true, NT_STATUS_INVALID_PARAMETER }, + { 6, false, NT_STATUS_INVALID_PARAMETER }, }; printf("Checking RAW_OPEN_NTCREATEX\n"); @@ -712,7 +713,7 @@ static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE); if (fnum == -1) { d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } smbcli_close(cli->tree, fnum); @@ -723,7 +724,7 @@ static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n", __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status), i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_disp); - ret = False; + ret = false; } if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) { smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); @@ -755,7 +756,7 @@ static BOOL test_ntcreatex(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) smbcli_unlink(cli->tree, fname); fnum = create_complex_file(cli, mem_ctx, fname); if (fnum == -1) { - ret = False; + ret = false; goto done; } smbcli_close(cli->tree, fnum); @@ -832,7 +833,7 @@ done: /* test RAW_OPEN_NTTRANS_CREATE */ -static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; union smb_fileinfo finfo; @@ -840,27 +841,27 @@ static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) const char *dname = BASEDIR "\\torture_ntcreatex.dir"; NTSTATUS status; int fnum = -1; - BOOL ret = True; + bool ret = true; int i; struct { uint32_t open_disp; - BOOL with_file; + bool with_file; NTSTATUS correct_status; } open_funcs[] = { - { NTCREATEX_DISP_SUPERSEDE, True, NT_STATUS_OK }, - { NTCREATEX_DISP_SUPERSEDE, False, NT_STATUS_OK }, - { NTCREATEX_DISP_OPEN, True, NT_STATUS_OK }, - { NTCREATEX_DISP_OPEN, False, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { NTCREATEX_DISP_CREATE, True, NT_STATUS_OBJECT_NAME_COLLISION }, - { NTCREATEX_DISP_CREATE, False, NT_STATUS_OK }, - { NTCREATEX_DISP_OPEN_IF, True, NT_STATUS_OK }, - { NTCREATEX_DISP_OPEN_IF, False, NT_STATUS_OK }, - { NTCREATEX_DISP_OVERWRITE, True, NT_STATUS_OK }, - { NTCREATEX_DISP_OVERWRITE, False, NT_STATUS_OBJECT_NAME_NOT_FOUND }, - { NTCREATEX_DISP_OVERWRITE_IF, True, NT_STATUS_OK }, - { NTCREATEX_DISP_OVERWRITE_IF, False, NT_STATUS_OK }, - { 6, True, NT_STATUS_INVALID_PARAMETER }, - { 6, False, NT_STATUS_INVALID_PARAMETER }, + { NTCREATEX_DISP_SUPERSEDE, true, NT_STATUS_OK }, + { NTCREATEX_DISP_SUPERSEDE, false, NT_STATUS_OK }, + { NTCREATEX_DISP_OPEN, true, NT_STATUS_OK }, + { NTCREATEX_DISP_OPEN, false, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { NTCREATEX_DISP_CREATE, true, NT_STATUS_OBJECT_NAME_COLLISION }, + { NTCREATEX_DISP_CREATE, false, NT_STATUS_OK }, + { NTCREATEX_DISP_OPEN_IF, true, NT_STATUS_OK }, + { NTCREATEX_DISP_OPEN_IF, false, NT_STATUS_OK }, + { NTCREATEX_DISP_OVERWRITE, true, NT_STATUS_OK }, + { NTCREATEX_DISP_OVERWRITE, false, NT_STATUS_OBJECT_NAME_NOT_FOUND }, + { NTCREATEX_DISP_OVERWRITE_IF, true, NT_STATUS_OK }, + { NTCREATEX_DISP_OVERWRITE_IF, false, NT_STATUS_OK }, + { 6, true, NT_STATUS_INVALID_PARAMETER }, + { 6, false, NT_STATUS_INVALID_PARAMETER }, }; printf("Checking RAW_OPEN_NTTRANS_CREATE\n"); @@ -887,7 +888,7 @@ static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR|O_TRUNC, DENY_NONE); if (fnum == -1) { d_printf("Failed to create file %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } smbcli_close(cli->tree, fnum); @@ -898,7 +899,7 @@ static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) printf("(%s) incorrect status %s should be %s (i=%d with_file=%d open_disp=%d)\n", __location__, nt_errstr(status), nt_errstr(open_funcs[i].correct_status), i, (int)open_funcs[i].with_file, (int)open_funcs[i].open_disp); - ret = False; + ret = false; } if (NT_STATUS_IS_OK(status) || open_funcs[i].with_file) { smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); @@ -930,7 +931,7 @@ static BOOL test_nttrans_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) smbcli_unlink(cli->tree, fname); fnum = create_complex_file(cli, mem_ctx, fname); if (fnum == -1) { - ret = False; + ret = false; goto done; } smbcli_close(cli->tree, fnum); @@ -1011,14 +1012,14 @@ done: open_disposition==NTCREATEX_DISP_OVERWRITE_IF. Windows 2003 allows the second open. */ -static BOOL test_ntcreatex_brlocked(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_ntcreatex_brlocked(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io, io1; union smb_lock io2; struct smb_lock_entry lock[1]; const char *fname = BASEDIR "\\torture_ntcreatex.txt"; NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("Testing ntcreatex with a byte range locked file\n"); @@ -1081,13 +1082,13 @@ static BOOL test_ntcreatex_brlocked(struct smbcli_state *cli, TALLOC_CTX *mem_ct /* test RAW_OPEN_MKNEW */ -static BOOL test_mknew(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_mknew(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; const char *fname = BASEDIR "\\torture_mknew.txt"; NTSTATUS status; int fnum = -1; - BOOL ret = True; + bool ret = true; time_t basetime = (time(NULL) + 3600*24*3) & ~1; union smb_fileinfo finfo; @@ -1136,13 +1137,13 @@ done: /* test RAW_OPEN_CREATE */ -static BOOL test_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_create(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; const char *fname = BASEDIR "\\torture_create.txt"; NTSTATUS status; int fnum = -1; - BOOL ret = True; + bool ret = true; time_t basetime = (time(NULL) + 3600*24*3) & ~1; union smb_fileinfo finfo; @@ -1192,12 +1193,12 @@ done: /* test RAW_OPEN_CTEMP */ -static BOOL test_ctemp(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_ctemp(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; NTSTATUS status; int fnum = -1; - BOOL ret = True; + bool ret = true; time_t basetime = (time(NULL) + 3600*24*3) & ~1; union smb_fileinfo finfo; const char *name, *fname = NULL; @@ -1235,13 +1236,13 @@ done: /* test chained RAW_OPEN_OPENX_READX */ -static BOOL test_chained(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_chained(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; const char *fname = BASEDIR "\\torture_chained.txt"; NTSTATUS status; int fnum = -1; - BOOL ret = True; + bool ret = true; const char *buf = "test"; char buf2[4]; @@ -1277,7 +1278,7 @@ static BOOL test_chained(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (memcmp(buf, buf2, sizeof(buf)) != 0) { d_printf("wrong data in reply buffer\n"); - ret = False; + ret = false; } done: @@ -1292,13 +1293,13 @@ done: NetApp filers are known to fail on this. */ -static BOOL test_no_leading_slash(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_no_leading_slash(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_open io; const char *fname = BASEDIR "\\torture_no_leading_slash.txt"; NTSTATUS status; int fnum = -1; - BOOL ret = True; + bool ret = true; const char *buf = "test"; printf("Checking RAW_OPEN_OPENX without leading slash on path\n"); @@ -1334,19 +1335,19 @@ done: /* A little torture test to expose a race condition in Samba 3.0.20 ... :-) */ -static BOOL test_raw_open_multi(void) +static bool test_raw_open_multi(void) { struct smbcli_state *cli; TALLOC_CTX *mem_ctx = talloc_init("torture_test_oplock_multi"); const char *fname = "\\test_oplock.dat"; NTSTATUS status; - BOOL ret = True; + bool ret = true; union smb_open io; struct smbcli_state **clients; struct smbcli_request **requests; union smb_open *ios; - const char *host = lp_parm_string(-1, "torture", "host"); - const char *share = lp_parm_string(-1, "torture", "share"); + const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host"); + const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share"); int i, num_files = 3; struct event_context *ev; int num_ok = 0; @@ -1359,11 +1360,11 @@ static BOOL test_raw_open_multi(void) if ((ev == NULL) || (clients == NULL) || (requests == NULL) || (ios == NULL)) { DEBUG(0, ("talloc failed\n")); - return False; + return false; } if (!torture_open_connection_share(mem_ctx, &cli, host, share, ev)) { - return False; + return false; } cli->tree->session->transport->options.request_timeout = 60000; @@ -1372,7 +1373,7 @@ static BOOL test_raw_open_multi(void) if (!torture_open_connection_share(mem_ctx, &(clients[i]), host, share, ev)) { DEBUG(0, ("Could not open %d'th connection\n", i)); - return False; + return false; } clients[i]->tree->session->transport-> options.request_timeout = 60000; @@ -1404,19 +1405,19 @@ static BOOL test_raw_open_multi(void) requests[i] = smb_raw_open_send(clients[i]->tree, &ios[i]); if (requests[i] == NULL) { DEBUG(0, ("could not send %d'th request\n", i)); - return False; + return false; } } DEBUG(10, ("waiting for replies\n")); while (1) { - BOOL unreplied = False; + bool unreplied = false; for (i=0; i<num_files; i++) { if (requests[i] == NULL) { continue; } if (requests[i]->state < SMBCLI_REQUEST_DONE) { - unreplied = True; + unreplied = true; break; } status = smb_raw_open_recv(requests[i], mem_ctx, @@ -1442,12 +1443,12 @@ static BOOL test_raw_open_multi(void) if (event_loop_once(ev) != 0) { DEBUG(0, ("event_loop_once failed\n")); - return False; + return false; } } if ((num_ok != 1) || (num_ok + num_collision != num_files)) { - ret = False; + ret = false; } for (i=0; i<num_files; i++) { diff --git a/source4/torture/raw/openbench.c b/source4/torture/raw/openbench.c index fffb572d50..a53efb3a8b 100644 --- a/source4/torture/raw/openbench.c +++ b/source4/torture/raw/openbench.c @@ -30,6 +30,7 @@ #include "lib/cmdline/popt_common.h" #include "libcli/composite/composite.h" #include "libcli/smb_composite/smb_composite.h" +#include "param/param.h" #define BASEDIR "\\benchopen" @@ -126,8 +127,8 @@ static void reopen_connection(struct event_context *ev, struct timed_event *te, io->in.service = share; io->in.service_type = state->service_type; io->in.credentials = cmdline_credentials; - io->in.fallback_to_anonymous = False; - io->in.workgroup = lp_workgroup(); + io->in.fallback_to_anonymous = false; + io->in.workgroup = lp_workgroup(global_loadparm); /* kill off the remnants of the old connection */ talloc_free(state->tree); @@ -337,9 +338,9 @@ static void report_rate(struct event_context *ev, struct timed_event *te, /* benchmark open calls */ -BOOL torture_bench_open(struct torture_context *torture) +bool torture_bench_open(struct torture_context *torture) { - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx = talloc_new(torture); int i; int timelimit = torture_setting_int(torture, "timelimit", 10); @@ -347,7 +348,7 @@ BOOL torture_bench_open(struct torture_context *torture) struct event_context *ev = event_context_find(mem_ctx); struct benchopen_state *state; int total = 0, minops=0; - bool progress=False; + bool progress=false; progress = torture_setting_bool(torture, "progress", true); @@ -361,7 +362,7 @@ BOOL torture_bench_open(struct torture_context *torture) state[i].client_num = i; state[i].ev = ev; if (!torture_open_connection_ev(&state[i].cli, i, ev)) { - return False; + return false; } talloc_steal(mem_ctx, state); state[i].tree = state[i].cli->tree; @@ -437,5 +438,5 @@ BOOL torture_bench_open(struct torture_context *torture) failed: talloc_free(mem_ctx); - return False; + return false; } diff --git a/source4/torture/raw/oplock.c b/source4/torture/raw/oplock.c index 7a921af422..1f44f96b44 100644 --- a/source4/torture/raw/oplock.c +++ b/source4/torture/raw/oplock.c @@ -29,14 +29,14 @@ if ((v) != (correct)) { \ torture_comment(tctx, "(%s): wrong value for %s got 0x%x - should be 0x%x\n", \ __location__, #v, (int)v, (int)correct); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_STATUS(tctx, status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ torture_result(tctx, TORTURE_FAIL, __location__": Incorrect status %s - should be %s", \ nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -53,10 +53,11 @@ static struct { /* a handler function for oplock break requests. Ack it as a break to level II if possible */ -static BOOL oplock_handler_ack_to_levelII(struct smbcli_transport *transport, uint16_t tid, - uint16_t fnum, uint8_t level, void *private) +static bool oplock_handler_ack_to_levelII(struct smbcli_transport *transport, + uint16_t tid, uint16_t fnum, + uint8_t level, void *private) { - struct smbcli_tree *tree = private; + struct smbcli_tree *tree = (struct smbcli_tree *)private; break_info.fnum = fnum; break_info.level = level; break_info.count++; @@ -69,11 +70,11 @@ static BOOL oplock_handler_ack_to_levelII(struct smbcli_transport *transport, ui /* a handler function for oplock break requests. Ack it as a break to none */ -static BOOL oplock_handler_ack_to_none(struct smbcli_transport *transport, uint16_t tid, - uint16_t fnum, uint8_t level, - void *private) +static bool oplock_handler_ack_to_none(struct smbcli_transport *transport, + uint16_t tid, uint16_t fnum, + uint8_t level, void *private) { - struct smbcli_tree *tree = private; + struct smbcli_tree *tree = (struct smbcli_tree *)private; break_info.fnum = fnum; break_info.level = level; break_info.count++; @@ -96,11 +97,11 @@ static void oplock_handler_close_recv(struct smbcli_request *req) /* a handler function for oplock break requests - close the file */ -static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t tid, +static bool oplock_handler_close(struct smbcli_transport *transport, uint16_t tid, uint16_t fnum, uint8_t level, void *private) { union smb_close io; - struct smbcli_tree *tree = private; + struct smbcli_tree *tree = (struct smbcli_tree *)private; struct smbcli_request *req; break_info.fnum = fnum; @@ -113,13 +114,13 @@ static BOOL oplock_handler_close(struct smbcli_transport *transport, uint16_t ti req = smb_raw_close_send(tree, &io); if (req == NULL) { printf("failed to send close in oplock_handler_close\n"); - return False; + return false; } req->async.fn = oplock_handler_close_recv; req->async.private = NULL; - return True; + return true; } static bool test_raw_oplock_normal(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) @@ -1308,10 +1309,10 @@ struct torture_suite *torture_raw_oplock(TALLOC_CTX *mem_ctx) /* stress testing of oplocks */ -BOOL torture_bench_oplock(struct torture_context *torture) +bool torture_bench_oplock(struct torture_context *torture) { struct smbcli_state **cli; - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx = talloc_new(torture); int torture_nprocs = torture_setting_int(torture, "nprocs", 4); int i, count=0; @@ -1325,7 +1326,7 @@ BOOL torture_bench_oplock(struct torture_context *torture) torture_comment(torture, "Opening %d connections\n", torture_nprocs); for (i=0;i<torture_nprocs;i++) { if (!torture_open_connection_ev(&cli[i], i, ev)) { - return False; + return false; } talloc_steal(mem_ctx, cli[i]); smbcli_oplock_handler(cli[i]->transport, oplock_handler_close, @@ -1333,7 +1334,7 @@ BOOL torture_bench_oplock(struct torture_context *torture) } if (!torture_setup_dir(cli[0], BASEDIR)) { - ret = False; + ret = false; goto done; } @@ -1396,20 +1397,21 @@ static struct hold_oplock_info { uint32_t share_access; uint16_t fnum; } hold_info[] = { - { BASEDIR "\\notshared_close", True, + { BASEDIR "\\notshared_close", true, NTCREATEX_SHARE_ACCESS_NONE, }, - { BASEDIR "\\notshared_noclose", False, + { BASEDIR "\\notshared_noclose", false, NTCREATEX_SHARE_ACCESS_NONE, }, - { BASEDIR "\\shared_close", True, + { BASEDIR "\\shared_close", true, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, }, - { BASEDIR "\\shared_noclose", False, + { BASEDIR "\\shared_noclose", false, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, }, }; -static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid, - uint16_t fnum, uint8_t level, void *private) +static bool oplock_handler_hold(struct smbcli_transport *transport, + uint16_t tid, uint16_t fnum, uint8_t level, + void *private) { - struct smbcli_tree *tree = private; + struct smbcli_tree *tree = (struct smbcli_tree *)private; struct hold_oplock_info *info; int i; @@ -1419,7 +1421,7 @@ static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid if (i == ARRAY_SIZE(hold_info)) { printf("oplock break for unknown fnum %u\n", fnum); - return False; + return false; } info = &hold_info[i]; @@ -1428,7 +1430,7 @@ static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid printf("oplock break on %s - closing\n", info->fname); oplock_handler_close(transport, tid, fnum, level, private); - return True; + return true; } printf("oplock break on %s - acking break\n", info->fname); @@ -1441,16 +1443,17 @@ static BOOL oplock_handler_hold(struct smbcli_transport *transport, uint16_t tid used for manual testing of oplocks - especially interaction with other filesystems (such as NFS and local access) */ -BOOL torture_hold_oplock(struct torture_context *torture, +bool torture_hold_oplock(struct torture_context *torture, struct smbcli_state *cli) { - struct event_context *ev = cli->transport->socket->event.ctx; + struct event_context *ev = + (struct event_context *)cli->transport->socket->event.ctx; int i; printf("Setting up open files with oplocks in %s\n", BASEDIR); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } smbcli_oplock_handler(cli->transport, oplock_handler_hold, cli->tree); @@ -1480,14 +1483,14 @@ BOOL torture_hold_oplock(struct torture_context *torture, if (!NT_STATUS_IS_OK(status)) { printf("Failed to open %s - %s\n", hold_info[i].fname, nt_errstr(status)); - return False; + return false; } if (io.ntcreatex.out.oplock_level != BATCH_OPLOCK_RETURN) { printf("Oplock not granted for %s - expected %d but got %d\n", hold_info[i].fname, BATCH_OPLOCK_RETURN, io.ntcreatex.out.oplock_level); - return False; + return false; } hold_info[i].fnum = io.ntcreatex.out.file.fnum; } @@ -1495,5 +1498,5 @@ BOOL torture_hold_oplock(struct torture_context *torture, printf("Waiting for oplock events\n"); event_loop_wait(ev); - return True; + return true; } diff --git a/source4/torture/raw/pingpong.c b/source4/torture/raw/pingpong.c index 027034275a..2e9de28d67 100755 --- a/source4/torture/raw/pingpong.c +++ b/source4/torture/raw/pingpong.c @@ -37,10 +37,10 @@ over and over until it completes. reading from the file can be enabled with - --option=torture:read=True + --option=torture:read=true writing to the file can be enabled with - --option=torture:write=True + --option=torture:write=true */ #include "includes.h" @@ -50,11 +50,9 @@ #include "system/filesys.h" #include "libcli/libcli.h" #include "torture/util.h" +#include "param/param.h" - - - -void lock_byte(struct smbcli_state *cli, int fd, int offset, int lock_timeout) +static void lock_byte(struct smbcli_state *cli, int fd, int offset, int lock_timeout) { union smb_lock io; struct smb_lock_entry lock; @@ -92,7 +90,7 @@ try_again: } } -void unlock_byte(struct smbcli_state *cli, int fd, int offset) +static void unlock_byte(struct smbcli_state *cli, int fd, int offset) { union smb_lock io; struct smb_lock_entry lock; @@ -119,7 +117,7 @@ void unlock_byte(struct smbcli_state *cli, int fd, int offset) } } -void write_byte(struct smbcli_state *cli, int fd, uint8_t c, int offset) +static void write_byte(struct smbcli_state *cli, int fd, uint8_t c, int offset) { union smb_write io; NTSTATUS status; @@ -139,7 +137,7 @@ void write_byte(struct smbcli_state *cli, int fd, uint8_t c, int offset) } } -void read_byte(struct smbcli_state *cli, int fd, uint8_t *c, int offset) +static void read_byte(struct smbcli_state *cli, int fd, uint8_t *c, int offset) { union smb_read io; NTSTATUS status; @@ -150,7 +148,7 @@ void read_byte(struct smbcli_state *cli, int fd, uint8_t *c, int offset) io.readx.in.maxcnt = 1; io.readx.in.offset = offset; io.readx.in.remaining = 0; - io.readx.in.read_for_execute = False; + io.readx.in.read_for_execute = false; io.readx.out.data = c; status = smb_raw_read(cli->tree, &io); @@ -178,13 +176,13 @@ static double end_timer(void) /* ping pong */ -BOOL torture_ping_pong(struct torture_context *torture) +bool torture_ping_pong(struct torture_context *torture) { const char *fn; int num_locks; TALLOC_CTX *mem_ctx = talloc_new(torture); - static BOOL do_reads; - static BOOL do_writes; + static bool do_reads; + static bool do_writes; int lock_timeout; int fd; struct smbcli_state *cli; @@ -193,21 +191,21 @@ BOOL torture_ping_pong(struct torture_context *torture) uint8_t *val; int count, loops; - fn = lp_parm_string(-1, "torture", "filename"); + fn = lp_parm_string(global_loadparm, NULL, "torture", "filename"); if (fn == NULL) { DEBUG(0,("You must specify the filename using --option=torture:filename=...\n")); return false; } - num_locks = lp_parm_int(-1, "torture", "num_locks", -1); + num_locks = lp_parm_int(global_loadparm, NULL, "torture", "num_locks", -1); if (num_locks == -1) { DEBUG(0,("You must specify num_locks using --option=torture:num_locks=...\n")); return false; } - do_reads = lp_parm_bool(-1, "torture", "read", False); - do_writes = lp_parm_bool(-1, "torture", "write", False); - lock_timeout = lp_parm_int(-1, "torture", "lock_timeout", 100000); + do_reads = lp_parm_bool(global_loadparm, NULL, "torture", "read", false); + do_writes = lp_parm_bool(global_loadparm, NULL, "torture", "write", false); + lock_timeout = lp_parm_int(global_loadparm, NULL, "torture", "lock_timeout", 100000); if (!torture_open_connection(&cli, 0)) { DEBUG(0,("Could not open connection\n")); diff --git a/source4/torture/raw/qfileinfo.c b/source4/torture/raw/qfileinfo.c index 8cb80cecc1..7dcd2000e9 100644 --- a/source4/torture/raw/qfileinfo.c +++ b/source4/torture/raw/qfileinfo.c @@ -25,6 +25,7 @@ #include "torture/util.h" #include "librpc/rpc/dcerpc.h" #include "torture/rpc/rpc.h" +#include "torture/raw/proto.h" static struct { const char *name; @@ -185,7 +186,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name) #n1, #v1, (uint_t)s1->n1.out.v1, \ #n2, #v2, (uint_t)s2->n2.out.v2, \ __FILE__, __LINE__); \ - ret = False; \ + ret = false; \ }} while(0) #define STR_EQUAL(n1, v1, n2, v2) do {if (strcmp_safe(s1->n1.out.v1.s, s2->n2.out.v2.s) || \ @@ -194,7 +195,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name) #n1, #v1, s1->n1.out.v1.s, s1->n1.out.v1.private_length, \ #n2, #v2, s2->n2.out.v2.s, s2->n2.out.v2.private_length, \ __FILE__, __LINE__); \ - ret = False; \ + ret = false; \ }} while(0) #define STRUCT_EQUAL(n1, v1, n2, v2) do {if (memcmp(&s1->n1.out.v1,&s2->n2.out.v2,sizeof(s1->n1.out.v1))) { \ @@ -202,7 +203,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name) #n1, #v1, \ #n2, #v2, \ __FILE__, __LINE__); \ - ret = False; \ + ret = false; \ }} while(0) /* used to find hints on unknown values - and to make sure @@ -214,7 +215,7 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name) (uint_t)s1->n1.out.v1, \ (uint_t)s1->n1.out.v1, \ __FILE__, __LINE__); \ - ret = False; \ + ret = false; \ }} while(0) #endif @@ -222,21 +223,21 @@ static union smb_fileinfo *fname_find(bool is_ipc, const char *name) for each call we test that it succeeds, and where possible test for consistency between the calls. */ -static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, +static bool torture_raw_qfileinfo_internals(struct torture_context *torture, TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, int fnum, const char *fname, bool is_ipc) { int i; - BOOL ret = True; + bool ret = true; int count; union smb_fileinfo *s1, *s2; NTTIME correct_time; uint64_t correct_size; uint32_t correct_attrib; const char *correct_name; - BOOL skip_streams = False; + bool skip_streams = false; /* scan all the fileinfo and pathinfo levels */ for (i=0; levels[i].name; i++) { @@ -292,11 +293,10 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, } if (count != 0) { - ret = False; + ret = false; printf("%d levels failed\n", count); if (count > 35) { - printf("too many level failures - giving up\n"); - goto done; + torture_fail(torture, "too many level failures - giving up"); } } @@ -307,7 +307,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, printf("STREAM_INFO broken (%d) - skipping streams checks\n", s1 ? s1->stream_info.out.num_streams : -1); } - skip_streams = True; + skip_streams = true; } @@ -401,14 +401,14 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ nt_time_string(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ - ret = False; \ + ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && memcmp(&s1->stype.out.tfield, &correct_time, sizeof(correct_time)) != 0) { \ printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ nt_time_string(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ - ret = False; \ + ret = false; \ }} while (0) #define TIME_CHECK_DOS(sname, stype, tfield) do { \ @@ -417,14 +417,14 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ timestring(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ - ret = False; \ + ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && dos_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \ printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ timestring(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ - ret = False; \ + ret = false; \ }} while (0) #if 0 /* unused */ @@ -434,21 +434,21 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, printf("(%d) handle %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ timestring(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ - ret = False; \ + ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && unx_nt_time_cmp(s1->stype.out.tfield, correct_time) != 0) { \ printf("(%d) path %s/%s incorrect - %s should be %s\n", __LINE__, #stype, #tfield, \ timestring(mem_ctx, s1->stype.out.tfield), \ nt_time_string(mem_ctx, correct_time)); \ - ret = False; \ + ret = false; \ }} while (0) #endif /* now check that all the times that are supposed to be equal are correct */ s1 = fnum_find("BASIC_INFO"); correct_time = s1->basic_info.out.create_time; - printf("create_time: %s\n", nt_time_string(mem_ctx, correct_time)); + torture_comment(torture, "create_time: %s\n", nt_time_string(mem_ctx, correct_time)); TIME_CHECK_NT ("BASIC_INFO", basic_info, create_time); TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, create_time); @@ -460,7 +460,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, s1 = fnum_find("BASIC_INFO"); correct_time = s1->basic_info.out.access_time; - printf("access_time: %s\n", nt_time_string(mem_ctx, correct_time)); + torture_comment(torture, "access_time: %s\n", nt_time_string(mem_ctx, correct_time)); TIME_CHECK_NT ("BASIC_INFO", basic_info, access_time); TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, access_time); @@ -472,7 +472,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, s1 = fnum_find("BASIC_INFO"); correct_time = s1->basic_info.out.write_time; - printf("write_time : %s\n", nt_time_string(mem_ctx, correct_time)); + torture_comment(torture, "write_time : %s\n", nt_time_string(mem_ctx, correct_time)); TIME_CHECK_NT ("BASIC_INFO", basic_info, write_time); TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, write_time); @@ -485,7 +485,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, s1 = fnum_find("BASIC_INFO"); correct_time = s1->basic_info.out.change_time; - printf("change_time: %s\n", nt_time_string(mem_ctx, correct_time)); + torture_comment(torture, "change_time: %s\n", nt_time_string(mem_ctx, correct_time)); TIME_CHECK_NT ("BASIC_INFO", basic_info, change_time); TIME_CHECK_NT ("BASIC_INFORMATION", basic_info, change_time); @@ -499,19 +499,19 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, printf("(%d) handle %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield, \ (uint_t)s1->stype.out.tfield, \ (uint_t)correct_size); \ - ret = False; \ + ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && s1->stype.out.tfield != correct_size) { \ printf("(%d) path %s/%s incorrect - %u should be %u\n", __LINE__, #stype, #tfield, \ (uint_t)s1->stype.out.tfield, \ (uint_t)correct_size); \ - ret = False; \ + ret = false; \ }} while (0) s1 = fnum_find("STANDARD_INFO"); correct_size = s1->standard_info.out.size; - printf("size: %u\n", (uint_t)correct_size); + torture_comment(torture, "size: %u\n", (uint_t)correct_size); SIZE_CHECK("GETATTR", getattr, size); SIZE_CHECK("GETATTRE", getattre, size); @@ -532,7 +532,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, s1 = fnum_find("STANDARD_INFO"); correct_size = s1->standard_info.out.alloc_size; - printf("alloc_size: %u\n", (uint_t)correct_size); + torture_comment(torture, "alloc_size: %u\n", (uint_t)correct_size); SIZE_CHECK("GETATTRE", getattre, alloc_size); SIZE_CHECK("STANDARD", standard, alloc_size); @@ -553,19 +553,19 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, printf("(%d) handle %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield, \ (uint_t)s1->stype.out.tfield, \ (uint_t)correct_attrib); \ - ret = False; \ + ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && s1->stype.out.tfield != correct_attrib) { \ printf("(%d) path %s/%s incorrect - 0x%x should be 0x%x\n", __LINE__, #stype, #tfield, \ (uint_t)s1->stype.out.tfield, \ (uint_t)correct_attrib); \ - ret = False; \ + ret = false; \ }} while (0) s1 = fnum_find("BASIC_INFO"); correct_attrib = s1->basic_info.out.attrib; - printf("attrib: 0x%x\n", (uint_t)correct_attrib); + torture_comment(torture, "attrib: 0x%x\n", (uint_t)correct_attrib); ATTRIB_CHECK("GETATTR", getattr, attrib); if (!is_ipc) { @@ -581,7 +581,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, ATTRIB_CHECK("ATTRIBUTE_TAG_INFORMATION", attribute_tag_information, attrib); correct_name = fname; - printf("name: %s\n", correct_name); + torture_comment(torture, "name: %s\n", correct_name); #define NAME_CHECK(sname, stype, tfield, flags) do { \ s1 = fnum_find(sname); \ @@ -589,14 +589,14 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \ printf("(%d) handle %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \ s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \ - ret = False; \ + ret = false; \ } \ s1 = fname_find(is_ipc, sname); \ if (s1 && (strcmp_safe(s1->stype.out.tfield.s, correct_name) != 0 || \ wire_bad_flags(&s1->stype.out.tfield, flags, tree->session->transport))) { \ printf("(%d) path %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \ s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \ - ret = False; \ + ret = false; \ }} while (0) NAME_CHECK("NAME_INFO", name_info, fname, STR_UNICODE); @@ -605,32 +605,31 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, /* the ALL_INFO file name is the full path on the filesystem */ s1 = fnum_find("ALL_INFO"); if (s1 && !s1->all_info.out.fname.s) { - printf("ALL_INFO didn't give a filename\n"); - ret = False; + torture_fail(torture, "ALL_INFO didn't give a filename"); } if (s1 && s1->all_info.out.fname.s) { char *p = strrchr(s1->all_info.out.fname.s, '\\'); if (!p) { printf("Not a full path in all_info/fname? - '%s'\n", s1->all_info.out.fname.s); - ret = False; + ret = false; } else { if (strcmp_safe(correct_name, p) != 0) { printf("incorrect basename in all_info/fname - '%s'\n", s1->all_info.out.fname.s); - ret = False; + ret = false; } } if (wire_bad_flags(&s1->all_info.out.fname, STR_UNICODE, tree->session->transport)) { printf("Should not null terminate all_info/fname\n"); - ret = False; + ret = false; } } s1 = fnum_find("ALT_NAME_INFO"); if (s1) { correct_name = s1->alt_name_info.out.fname.s; - printf("alt_name: %s\n", correct_name); + torture_comment(torture, "alt_name: %s\n", correct_name); NAME_CHECK("ALT_NAME_INFO", alt_name_info, fname, STR_UNICODE); NAME_CHECK("ALT_NAME_INFORMATION", alt_name_info, fname, STR_UNICODE); @@ -647,12 +646,12 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, 0, 0); if (fnum == -1) { printf("Unable to open by alt_name - %s\n", smbcli_errstr(tree)); - ret = False; + ret = false; } if (!skip_streams) { correct_name = "::$DATA"; - printf("stream_name: %s\n", correct_name); + torture_comment(torture, "stream_name: %s\n", correct_name); NAME_CHECK("STREAM_INFO", stream_info, streams[0].stream_name, STR_UNICODE); NAME_CHECK("STREAM_INFORMATION", stream_info, streams[0].stream_name, STR_UNICODE); @@ -703,28 +702,28 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, printf("(%d) handle %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \ #stype1, #tfield1, #stype2, #tfield2, \ s1->stype1.out.tfield1, s2->stype2.out.tfield2); \ - ret = False; \ + ret = false; \ } \ s1 = fname_find(is_ipc, sname1); s2 = fname_find(is_ipc, sname2); \ if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \ printf("(%d) path %s/%s != %s/%s - 0x%x vs 0x%x\n", __LINE__, \ #stype1, #tfield1, #stype2, #tfield2, \ s1->stype1.out.tfield1, s2->stype2.out.tfield2); \ - ret = False; \ + ret = false; \ } \ s1 = fnum_find(sname1); s2 = fname_find(is_ipc, sname2); \ if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \ printf("(%d) handle %s/%s != path %s/%s - 0x%x vs 0x%x\n", __LINE__, \ #stype1, #tfield1, #stype2, #tfield2, \ s1->stype1.out.tfield1, s2->stype2.out.tfield2); \ - ret = False; \ + ret = false; \ } \ s1 = fname_find(is_ipc, sname1); s2 = fnum_find(sname2); \ if (s1 && s2 && s1->stype1.out.tfield1 != s2->stype2.out.tfield2) { \ printf("(%d) path %s/%s != handle %s/%s - 0x%x vs 0x%x\n", __LINE__, \ #stype1, #tfield1, #stype2, #tfield2, \ s1->stype1.out.tfield1, s2->stype2.out.tfield2); \ - ret = False; \ + ret = false; \ }} while (0) VAL_CHECK("STANDARD_INFO", standard_info, delete_pending, @@ -737,18 +736,18 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, if (s1 && is_ipc) { if (s1->basic_info.out.attrib != FILE_ATTRIBUTE_NORMAL) { printf("(%d) attrib basic_info/nlink incorrect - %d should be %d\n", __LINE__, s1->basic_info.out.attrib, FILE_ATTRIBUTE_NORMAL); - ret = False; + ret = false; } } s1 = fnum_find("STANDARD_INFO"); if (s1 && is_ipc) { if (s1->standard_info.out.nlink != 1) { printf("(%d) nlinks standard_info/nlink incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.nlink); - ret = False; + ret = false; } if (s1->standard_info.out.delete_pending != 1) { printf("(%d) nlinks standard_info/delete_pending incorrect - %d should be 1\n", __LINE__, s1->standard_info.out.delete_pending); - ret = False; + ret = false; } } VAL_CHECK("EA_INFO", ea_info, ea_size, @@ -768,7 +767,7 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, s1 = fnum_find("INTERNAL_INFORMATION"); if (s1) { - printf("file_id=%.0f\n", (double)s1->internal_information.out.file_id); + torture_comment(torture, "file_id=%.0f\n", (double)s1->internal_information.out.file_id); } NAME_PATH_CHECK("INTERNAL_INFORMATION", internal_information, file_id); @@ -808,9 +807,6 @@ static BOOL torture_raw_qfileinfo_internals(struct torture_context *torture, /* when we set the delete disposition then the link count should drop to 0 and delete_pending should be 1 */ - -done: - return ret; } @@ -831,7 +827,7 @@ bool torture_raw_qfileinfo(struct torture_context *torture, return false; } - ret = torture_raw_qfileinfo_internals(torture, torture, cli->tree, fnum, fname, False /* is_ipc */); + ret = torture_raw_qfileinfo_internals(torture, torture, cli->tree, fnum, fname, false /* is_ipc */); smbcli_close(cli->tree, fnum); smbcli_unlink(cli->tree, fname); @@ -840,7 +836,7 @@ bool torture_raw_qfileinfo(struct torture_context *torture, } bool torture_raw_qfileinfo_pipe(struct torture_context *torture, - struct smbcli_state *cli) + struct smbcli_state *cli) { bool ret = true; int fnum; @@ -849,23 +845,17 @@ bool torture_raw_qfileinfo_pipe(struct torture_context *torture, struct smbcli_tree *ipc_tree; NTSTATUS status; - if (!(p = dcerpc_pipe_init(torture, - cli->tree->session->transport->socket->event.ctx))) { - return False; + if (!(p = dcerpc_pipe_init(torture, cli->tree->session->transport->socket->event.ctx))) { + return false; } status = dcerpc_pipe_open_smb(p, cli->tree, fname); - if (!NT_STATUS_IS_OK(status)) { - d_printf("dcerpc_pipe_open_smb failed: %s\n", - nt_errstr(status)); - talloc_free(p); - return False; - } + torture_assert_ntstatus_ok(torture, status, "dcerpc_pipe_open_smb failed"); ipc_tree = dcerpc_smb_tree(p->conn); fnum = dcerpc_smb_fnum(p->conn); - ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, True /* is_ipc */); + ret = torture_raw_qfileinfo_internals(torture, torture, ipc_tree, fnum, fname, true /* is_ipc */); talloc_free(p); return ret; diff --git a/source4/torture/raw/qfsinfo.c b/source4/torture/raw/qfsinfo.c index dc09e55b63..3207558624 100644 --- a/source4/torture/raw/qfsinfo.c +++ b/source4/torture/raw/qfsinfo.c @@ -74,7 +74,7 @@ static union smb_fsinfo *find(const char *name) #n1, #v1, (uint_t)s1->n1.out.v1, \ #n2, #v2, (uint_t)s2->n2.out.v2, \ __FILE__, __LINE__); \ - ret = False; \ + ret = false; \ }} while(0) #define VAL_APPROX_EQUAL(n1, v1, n2, v2) do {if (abs((int)(s1->n1.out.v1) - (int)(s2->n2.out.v2)) > 0.1*s1->n1.out.v1) { \ @@ -82,7 +82,7 @@ static union smb_fsinfo *find(const char *name) #n1, #v1, (uint_t)s1->n1.out.v1, \ #n2, #v2, (uint_t)s2->n2.out.v2, \ __FILE__, __LINE__); \ - ret = False; \ + ret = false; \ }} while(0) #define STR_EQUAL(n1, v1, n2, v2) do { \ @@ -91,7 +91,7 @@ static union smb_fsinfo *find(const char *name) #n1, #v1, s1->n1.out.v1, \ #n2, #v2, s2->n2.out.v2, \ __FILE__, __LINE__); \ - ret = False; \ + ret = false; \ }} while(0) #define STRUCT_EQUAL(n1, v1, n2, v2) do {if (memcmp(&s1->n1.out.v1,&s2->n2.out.v2,sizeof(s1->n1.out.v1))) { \ @@ -99,7 +99,7 @@ static union smb_fsinfo *find(const char *name) #n1, #v1, \ #n2, #v2, \ __FILE__, __LINE__); \ - ret = False; \ + ret = false; \ }} while(0) /* used to find hints on unknown values - and to make sure @@ -110,7 +110,7 @@ static union smb_fsinfo *find(const char *name) (uint_t)s1->n1.out.v1, \ (uint_t)s1->n1.out.v1, \ __FILE__, __LINE__); \ - ret = False; \ + ret = false; \ }} while(0) /* basic testing of all RAW_QFS_* calls @@ -121,10 +121,10 @@ static union smb_fsinfo *find(const char *name) quiescent, which is sometimes hard to achieve */ bool torture_raw_qfsinfo(struct torture_context *torture, - struct smbcli_state *cli) + struct smbcli_state *cli) { int i; - BOOL ret = True; + bool ret = true; int count; union smb_fsinfo *s1, *s2; @@ -154,7 +154,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture, printf("%d levels failed\n", count); if (count > 13) { printf("too many level failures - giving up\n"); - return False; + return false; } } @@ -212,7 +212,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture, if (abs(size1 - size2) > 1) { printf("Inconsistent total size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n", size1, size2); - ret = False; + ret = false; } printf("total disk = %.0f MB\n", size1*scale/1.0e6); } @@ -234,7 +234,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture, if (abs(size1 - size2) > 1) { printf("Inconsistent avail size in DSKATTR and ALLOCATION - size1=%.0f size2=%.0f\n", size1, size2); - ret = False; + ret = false; } printf("free disk = %.0f MB\n", size1*scale/1.0e6); } @@ -283,7 +283,7 @@ bool torture_raw_qfsinfo(struct torture_context *torture, if (s1->stype.out.field.s && wire_bad_flags(&s1->stype.out.field, flags, cli->transport)) { \ printf("(%d) incorrect string termination in %s/%s\n", \ __LINE__, #stype, #field); \ - ret = False; \ + ret = false; \ } \ }} while (0) diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c index 0c4a28e0d6..112c34d299 100644 --- a/source4/torture/raw/raw.c +++ b/source4/torture/raw/raw.c @@ -63,6 +63,8 @@ NTSTATUS torture_raw_init(void) torture_suite_add_1smb_test(suite, "COMPOSITE", torture_raw_composite); torture_suite_add_simple_test(suite, "SAMBA3HIDE", torture_samba3_hide); torture_suite_add_simple_test(suite, "SAMBA3CLOSEERR", torture_samba3_closeerr); + torture_suite_add_simple_test(suite, "SAMBA3ROOTDIRFID", + torture_samba3_rootdirfid); torture_suite_add_simple_test(suite, "SAMBA3CHECKFSP", torture_samba3_checkfsp); torture_suite_add_simple_test(suite, "SAMBA3BADPATH", torture_samba3_badpath); torture_suite_add_simple_test(suite, "SAMBA3CASEINSENSITIVE", @@ -71,8 +73,7 @@ NTSTATUS torture_raw_init(void) torture_samba3_posixtimedlock); torture_suite_add_simple_test(suite, "SCAN-EAMAX", torture_max_eas); - suite->description = talloc_strdup(suite, - "Tests for the raw SMB interface"); + suite->description = talloc_strdup(suite, "Tests for the raw SMB interface"); torture_register_suite(suite); diff --git a/source4/torture/raw/read.c b/source4/torture/raw/read.c index f1048f25ac..90f6a3d4a8 100644 --- a/source4/torture/raw/read.c +++ b/source4/torture/raw/read.c @@ -24,12 +24,13 @@ #include "system/filesys.h" #include "libcli/libcli.h" #include "torture/util.h" +#include "param/param.h" #define CHECK_STATUS(status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -37,13 +38,13 @@ if ((v) != (correct)) { \ printf("(%s) Incorrect value %s=%ld - should be %ld\n", \ __location__, #v, (long)v, (long)correct); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) #define CHECK_BUFFER(buf, seed, len) do { \ if (!check_buffer(buf, seed, len, __LINE__)) { \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -63,7 +64,7 @@ static void setup_buffer(uint8_t *buf, uint_t seed, int len) /* check a random buffer based on a seed */ -static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, int line) +static bool check_buffer(uint8_t *buf, uint_t seed, int len, int line) { int i; srandom(seed); @@ -72,10 +73,10 @@ static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, int line) if (buf[i] != v) { printf("Buffer incorrect at line %d! ofs=%d v1=0x%x v2=0x%x\n", line, i, buf[i], v); - return False; + return false; } } - return True; + return true; } /* @@ -85,7 +86,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli) { union smb_read io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; uint8_t *buf; const int maxsize = 90000; @@ -93,10 +94,10 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli) const char *test_data = "TEST DATA"; uint_t seed = time(NULL); - buf = talloc_zero_size(tctx, maxsize); + buf = talloc_zero_array(tctx, uint8_t, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_READ_READ\n"); @@ -105,7 +106,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli) fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -143,7 +144,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli) CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(io.read.out.nread, strlen(test_data)); if (memcmp(buf, test_data, strlen(test_data)) != 0) { - ret = False; + ret = false; printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data, buf); goto done; } @@ -155,7 +156,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli) CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(io.read.out.nread, strlen(test_data)-1); if (memcmp(buf, test_data+1, strlen(test_data)-1) != 0) { - ret = False; + ret = false; printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data+1, buf); goto done; } @@ -185,7 +186,7 @@ static bool test_read(struct torture_context *tctx, struct smbcli_state *cli) cli->session->pid++; if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) { printf("Failed to lock file at %d\n", __LINE__); - ret = False; + ret = false; goto done; } cli->session->pid--; @@ -212,7 +213,7 @@ static bool test_lockread(struct torture_context *tctx, { union smb_read io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; uint8_t *buf; const int maxsize = 90000; @@ -220,10 +221,10 @@ static bool test_lockread(struct torture_context *tctx, const char *test_data = "TEST DATA"; uint_t seed = time(NULL); - buf = talloc_zero_size(tctx, maxsize); + buf = talloc_zero_array(tctx, uint8_t, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_READ_LOCKREAD\n"); @@ -232,7 +233,7 @@ static bool test_lockread(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -282,7 +283,7 @@ static bool test_lockread(struct torture_context *tctx, CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(io.lockread.out.nread, strlen(test_data)); if (memcmp(buf, test_data, strlen(test_data)) != 0) { - ret = False; + ret = false; printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data, buf); goto done; } @@ -298,7 +299,7 @@ static bool test_lockread(struct torture_context *tctx, CHECK_VALUE(io.lockread.out.nread, strlen(test_data)-1); if (memcmp(buf, test_data+1, strlen(test_data)-1) != 0) { - ret = False; + ret = false; printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data+1, buf); goto done; } @@ -332,7 +333,7 @@ static bool test_lockread(struct torture_context *tctx, cli->session->pid++; if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) { printf("Failed to lock file at %d\n", __LINE__); - ret = False; + ret = false; goto done; } cli->session->pid--; @@ -357,7 +358,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) { union smb_read io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; uint8_t *buf; const int maxsize = 90000; @@ -365,10 +366,10 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) const char *test_data = "TEST DATA"; uint_t seed = time(NULL); - buf = talloc_zero_size(tctx, maxsize); + buf = talloc_zero_array(tctx, uint8_t, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_READ_READX\n"); @@ -376,7 +377,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -387,7 +388,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) io.readx.in.maxcnt = 1; io.readx.in.offset = 0; io.readx.in.remaining = 0; - io.readx.in.read_for_execute = False; + io.readx.in.read_for_execute = false; io.readx.out.data = buf; status = smb_raw_read(cli->tree, &io); @@ -417,7 +418,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) io.readx.in.file.fnum = fnum; io.readx.in.offset = 0; io.readx.in.remaining = 0; - io.readx.in.read_for_execute = False; + io.readx.in.read_for_execute = false; io.readx.in.mincnt = strlen(test_data); io.readx.in.maxcnt = strlen(test_data); status = smb_raw_read(cli->tree, &io); @@ -426,7 +427,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) CHECK_VALUE(io.readx.out.remaining, 0xFFFF); CHECK_VALUE(io.readx.out.compaction_mode, 0); if (memcmp(buf, test_data, strlen(test_data)) != 0) { - ret = False; + ret = false; printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data, buf); goto done; } @@ -441,7 +442,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) CHECK_VALUE(io.readx.out.remaining, 0xFFFF); CHECK_VALUE(io.readx.out.compaction_mode, 0); if (memcmp(buf, test_data+1, strlen(test_data)-1) != 0) { - ret = False; + ret = false; printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data+1, buf); goto done; } @@ -481,7 +482,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(io.readx.out.remaining, 0xFFFF); CHECK_VALUE(io.readx.out.compaction_mode, 0); - if (lp_parm_bool(-1, "torture", "samba3", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { printf("SAMBA3: large read extension\n"); CHECK_VALUE(io.readx.out.nread, 80000); } else { @@ -525,7 +526,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) io.readx.in.maxcnt = 0x10000; status = smb_raw_read(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_OK); - if (lp_parm_bool(-1, "torture", "samba3", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { printf("SAMBA3: large read extension\n"); CHECK_VALUE(io.readx.out.nread, 0x10000); } else { @@ -535,7 +536,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) io.readx.in.maxcnt = 0x10001; status = smb_raw_read(cli->tree, &io); CHECK_STATUS(status, NT_STATUS_OK); - if (lp_parm_bool(-1, "torture", "samba3", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { printf("SAMBA3: large read extension\n"); CHECK_VALUE(io.readx.out.nread, 0x10001); } else { @@ -547,7 +548,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) cli->session->pid++; if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) { printf("Failed to lock file at %d\n", __LINE__); - ret = False; + ret = false; goto done; } cli->session->pid--; @@ -573,7 +574,7 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) if (NT_STATUS_IS_ERR(smbcli_lock64(cli->tree, fnum, io.readx.in.offset, 1, 0, WRITE_LOCK))) { printf("Failed to lock file at %d\n", __LINE__); - ret = False; + ret = false; goto done; } @@ -596,7 +597,7 @@ static bool test_readbraw(struct torture_context *tctx, { union smb_read io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; uint8_t *buf; const int maxsize = 90000; @@ -604,10 +605,10 @@ static bool test_readbraw(struct torture_context *tctx, const char *test_data = "TEST DATA"; uint_t seed = time(NULL); - buf = talloc_zero_size(tctx, maxsize); + buf = talloc_zero_array(tctx, uint8_t, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_READ_READBRAW\n"); @@ -615,7 +616,7 @@ static bool test_readbraw(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -657,7 +658,7 @@ static bool test_readbraw(struct torture_context *tctx, CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(io.readbraw.out.nread, strlen(test_data)); if (memcmp(buf, test_data, strlen(test_data)) != 0) { - ret = False; + ret = false; printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data, buf); goto done; } @@ -670,7 +671,7 @@ static bool test_readbraw(struct torture_context *tctx, CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(io.readbraw.out.nread, strlen(test_data)-1); if (memcmp(buf, test_data+1, strlen(test_data)-1) != 0) { - ret = False; + ret = false; printf("incorrect data at %d!? (%s:%s)\n", __LINE__, test_data+1, buf); goto done; } @@ -722,7 +723,7 @@ static bool test_readbraw(struct torture_context *tctx, cli->session->pid++; if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 103, 1, 0, WRITE_LOCK))) { printf("Failed to lock file at %d\n", __LINE__); - ret = False; + ret = false; goto done; } cli->session->pid--; @@ -771,17 +772,17 @@ static bool test_read_for_execute(struct torture_context *tctx, union smb_write wr; union smb_read rd; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum=0; uint8_t *buf; const int maxsize = 900; const char *fname = BASEDIR "\\test.txt"; const uint8_t data[] = "TEST DATA"; - buf = talloc_zero_size(tctx, maxsize); + buf = talloc_zero_array(tctx, uint8_t, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_READ_READX with read_for_execute\n"); @@ -840,7 +841,7 @@ static bool test_read_for_execute(struct torture_context *tctx, rd.readx.in.maxcnt = maxsize; rd.readx.in.offset = 0; rd.readx.in.remaining = 0; - rd.readx.in.read_for_execute = True; + rd.readx.in.read_for_execute = true; rd.readx.out.data = buf; status = smb_raw_read(cli->tree, &rd); CHECK_STATUS(status, NT_STATUS_OK); @@ -855,7 +856,7 @@ static bool test_read_for_execute(struct torture_context *tctx, rd.readx.in.maxcnt = maxsize; rd.readx.in.offset = 0; rd.readx.in.remaining = 0; - rd.readx.in.read_for_execute = False; + rd.readx.in.read_for_execute = false; rd.readx.out.data = buf; status = smb_raw_read(cli->tree, &rd); CHECK_STATUS(status, NT_STATUS_ACCESS_DENIED); @@ -887,7 +888,7 @@ static bool test_read_for_execute(struct torture_context *tctx, rd.readx.in.maxcnt = maxsize; rd.readx.in.offset = 0; rd.readx.in.remaining = 0; - rd.readx.in.read_for_execute = True; + rd.readx.in.read_for_execute = true; rd.readx.out.data = buf; status = smb_raw_read(cli->tree, &rd); CHECK_STATUS(status, NT_STATUS_OK); @@ -902,7 +903,7 @@ static bool test_read_for_execute(struct torture_context *tctx, rd.readx.in.maxcnt = maxsize; rd.readx.in.offset = 0; rd.readx.in.remaining = 0; - rd.readx.in.read_for_execute = False; + rd.readx.in.read_for_execute = false; rd.readx.out.data = buf; status = smb_raw_read(cli->tree, &rd); CHECK_STATUS(status, NT_STATUS_OK); diff --git a/source4/torture/raw/rename.c b/source4/torture/raw/rename.c index 05a5320859..4b0d986659 100644 --- a/source4/torture/raw/rename.c +++ b/source4/torture/raw/rename.c @@ -27,7 +27,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -35,7 +35,7 @@ if ((v) != (correct)) { \ printf("(%s) Incorrect %s %d - should be %d\n", \ __location__, #v, (int)v, (int)correct); \ - ret = False; \ + ret = false; \ }} while (0) #define BASEDIR "\\testrename" @@ -48,7 +48,7 @@ static bool test_mv(struct torture_context *tctx, { union smb_rename io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum = -1; const char *fname1 = BASEDIR "\\test1.txt"; const char *fname2 = BASEDIR "\\test2.txt"; @@ -59,7 +59,7 @@ static bool test_mv(struct torture_context *tctx, printf("Testing SMBmv\n"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Trying simple rename\n"); @@ -197,7 +197,7 @@ static bool test_ntrename(struct torture_context *tctx, { union smb_rename io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum, i; const char *fname1 = BASEDIR "\\test1.txt"; const char *fname2 = BASEDIR "\\test2.txt"; @@ -206,7 +206,7 @@ static bool test_ntrename(struct torture_context *tctx, printf("Testing SMBntrename\n"); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Trying simple rename\n"); diff --git a/source4/torture/raw/samba3hide.c b/source4/torture/raw/samba3hide.c index 3fe151f009..8fe3aa4d2d 100644 --- a/source4/torture/raw/samba3hide.c +++ b/source4/torture/raw/samba3hide.c @@ -57,7 +57,7 @@ static void init_unixinfo_nochange(union smb_setfileinfo *info) struct list_state { const char *fname; - BOOL visible; + bool visible; }; static void set_visible(struct clilist_file_info *i, const char *mask, @@ -66,43 +66,43 @@ static void set_visible(struct clilist_file_info *i, const char *mask, struct list_state *state = (struct list_state *)priv; if (strcasecmp_m(state->fname, i->name) == 0) - state->visible = True; + state->visible = true; } -static BOOL is_visible(struct smbcli_tree *tree, const char *fname) +static bool is_visible(struct smbcli_tree *tree, const char *fname) { struct list_state state; - state.visible = False; + state.visible = false; state.fname = fname; if (smbcli_list(tree, "*.*", 0, set_visible, &state) < 0) { - return False; + return false; } return state.visible; } -static BOOL is_readable(struct smbcli_tree *tree, const char *fname) +static bool is_readable(struct smbcli_tree *tree, const char *fname) { int fnum; fnum = smbcli_open(tree, fname, O_RDONLY, DENY_NONE); if (fnum < 0) { - return False; + return false; } smbcli_close(tree, fnum); - return True; + return true; } -static BOOL is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, +static bool is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, const char *fname) { int fnum; fnum = smbcli_open(tree, fname, O_WRONLY, DENY_NONE); if (fnum < 0) { - return False; + return false; } smbcli_close(tree, fnum); - return True; + return true; } /* @@ -110,7 +110,7 @@ static BOOL is_writeable(TALLOC_CTX *mem_ctx, struct smbcli_tree *tree, * might fail. But for our purposes it's sufficient. */ -static BOOL smbcli_file_exists(struct smbcli_tree *tree, const char *fname) +static bool smbcli_file_exists(struct smbcli_tree *tree, const char *fname) { return NT_STATUS_IS_OK(smbcli_getatr(tree, fname, NULL, NULL, NULL)); } @@ -125,7 +125,7 @@ static NTSTATUS smbcli_chmod(struct smbcli_tree *tree, const char *fname, return smb_raw_setpathinfo(tree, &sfinfo); } -BOOL torture_samba3_hide(struct torture_context *torture) +bool torture_samba3_hide(struct torture_context *torture) { struct smbcli_state *cli; const char *fname = "test.txt"; @@ -138,7 +138,7 @@ BOOL torture_samba3_hide(struct torture_context *torture) torture, &cli, torture_setting_string(torture, "host", NULL), torture_setting_string(torture, "share", NULL), NULL)) { d_printf("torture_open_connection_share failed\n"); - return False; + return false; } status = torture_second_tcon(torture, cli->session, "hideunread", @@ -146,7 +146,7 @@ BOOL torture_samba3_hide(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("second_tcon(hideunread) failed: %s\n", nt_errstr(status)); - return False; + return false; } status = torture_second_tcon(torture, cli->session, "hideunwrite", @@ -154,7 +154,7 @@ BOOL torture_samba3_hide(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("second_tcon(hideunwrite) failed: %s\n", nt_errstr(status)); - return False; + return false; } status = smbcli_unlink(cli->tree, fname); @@ -167,14 +167,14 @@ BOOL torture_samba3_hide(struct torture_context *torture) if (fnum == -1) { d_printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - return False; + return false; } smbcli_close(cli->tree, fnum); if (!smbcli_file_exists(cli->tree, fname)) { d_printf("%s does not exist\n", fname); - return False; + return false; } /* R/W file should be visible everywhere */ @@ -182,27 +182,27 @@ BOOL torture_samba3_hide(struct torture_context *torture) status = smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); - return False; + return false; } if (!is_writeable(torture, cli->tree, fname)) { d_printf("File not writable\n"); - return False; + return false; } if (!is_readable(cli->tree, fname)) { d_printf("File not readable\n"); - return False; + return false; } if (!is_visible(cli->tree, fname)) { d_printf("r/w file not visible via normal share\n"); - return False; + return false; } if (!is_visible(hideunread, fname)) { d_printf("r/w file not visible via hide unreadable\n"); - return False; + return false; } if (!is_visible(hideunwrite, fname)) { d_printf("r/w file not visible via hide unwriteable\n"); - return False; + return false; } /* R/O file should not be visible via hide unwriteable files */ @@ -211,27 +211,27 @@ BOOL torture_samba3_hide(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); - return False; + return false; } if (is_writeable(torture, cli->tree, fname)) { d_printf("r/o is writable\n"); - return False; + return false; } if (!is_readable(cli->tree, fname)) { d_printf("r/o not readable\n"); - return False; + return false; } if (!is_visible(cli->tree, fname)) { d_printf("r/o file not visible via normal share\n"); - return False; + return false; } if (!is_visible(hideunread, fname)) { d_printf("r/o file not visible via hide unreadable\n"); - return False; + return false; } if (is_visible(hideunwrite, fname)) { d_printf("r/o file visible via hide unwriteable\n"); - return False; + return false; } /* inaccessible file should be only visible on normal share */ @@ -239,33 +239,33 @@ BOOL torture_samba3_hide(struct torture_context *torture) status = smbcli_chmod(cli->tree, fname, 0); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_chmod failed: %s\n", nt_errstr(status)); - return False; + return false; } if (is_writeable(torture, cli->tree, fname)) { d_printf("inaccessible file is writable\n"); - return False; + return false; } if (is_readable(cli->tree, fname)) { d_printf("inaccessible file is readable\n"); - return False; + return false; } if (!is_visible(cli->tree, fname)) { d_printf("inaccessible file not visible via normal share\n"); - return False; + return false; } if (is_visible(hideunread, fname)) { d_printf("inaccessible file visible via hide unreadable\n"); - return False; + return false; } if (is_visible(hideunwrite, fname)) { d_printf("inaccessible file visible via hide unwriteable\n"); - return False; + return false; } smbcli_chmod(cli->tree, fname, UNIX_R_USR|UNIX_W_USR); smbcli_unlink(cli->tree, fname); - return True; + return true; } /* @@ -274,10 +274,10 @@ BOOL torture_samba3_hide(struct torture_context *torture) * close. smb_close should return NT_STATUS_ACCESS_DENIED. */ -BOOL torture_samba3_closeerr(struct torture_context *tctx) +bool torture_samba3_closeerr(struct torture_context *tctx) { struct smbcli_state *cli = NULL; - BOOL result = False; + bool result = false; NTSTATUS status; const char *dname = "closeerr.dir"; const char *fname = "closeerr.dir\\closerr.txt"; @@ -311,7 +311,7 @@ BOOL torture_samba3_closeerr(struct torture_context *tctx) talloc_asprintf(tctx, "smbcli_open failed: %s\n", smbcli_errstr(cli->tree))); - status = smbcli_nt_delete_on_close(cli->tree, fnum, True); + status = smbcli_nt_delete_on_close(cli->tree, fnum, true); torture_assert_ntstatus_ok(tctx, status, "setting delete_on_close on file failed !"); @@ -329,7 +329,7 @@ BOOL torture_samba3_closeerr(struct torture_context *tctx) torture_assert_ntstatus_equal(tctx, status, NT_STATUS_ACCESS_DENIED, "smbcli_close"); - result = True; + result = true; fail: if (cli) { diff --git a/source4/torture/raw/samba3misc.c b/source4/torture/raw/samba3misc.c index e1b1fcaf6d..988405e806 100644 --- a/source4/torture/raw/samba3misc.c +++ b/source4/torture/raw/samba3misc.c @@ -25,23 +25,24 @@ #include "libcli/libcli.h" #include "torture/util.h" #include "lib/events/events.h" +#include "param/param.h" #define CHECK_STATUS(status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ } \ } while (0) -BOOL torture_samba3_checkfsp(struct torture_context *torture) +bool torture_samba3_checkfsp(struct torture_context *torture) { struct smbcli_state *cli; const char *fname = "test.txt"; const char *dirname = "testdir"; int fnum; NTSTATUS status; - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx; ssize_t nread; char buf[16]; @@ -49,14 +50,14 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture) if ((mem_ctx = talloc_init("torture_samba3_checkfsp")) == NULL) { d_printf("talloc_init failed\n"); - return False; + return false; } if (!torture_open_connection_share( torture, &cli, torture_setting_string(torture, "host", NULL), torture_setting_string(torture, "share", NULL), NULL)) { d_printf("torture_open_connection_share failed\n"); - ret = False; + ret = false; goto done; } @@ -79,7 +80,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture) status = smbcli_mkdir(cli->tree, dirname); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } @@ -102,7 +103,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("smb_open on the directory failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } fnum = io.ntcreatex.out.file.fnum; @@ -114,7 +115,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture) if (nread >= 0) { d_printf("smbcli_read on a directory succeeded, expected " "failure\n"); - ret = False; + ret = false; } CHECK_STATUS(smbcli_nt_error(cli->tree), @@ -126,7 +127,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture) if (nread >= 0) { d_printf("smbcli_read on a directory succeeded, expected " "failure\n"); - ret = False; + ret = false; } CHECK_STATUS(smbcli_nt_error(tree2), NT_STATUS_INVALID_HANDLE); @@ -139,7 +140,7 @@ BOOL torture_samba3_checkfsp(struct torture_context *torture) if (fnum == -1) { d_printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -323,7 +324,7 @@ static NTSTATUS raw_smbcli_ntcreate(struct smbcli_tree *tree, const char *fname, } -BOOL torture_samba3_badpath(struct torture_context *torture) +bool torture_samba3_badpath(struct torture_context *torture) { struct smbcli_state *cli_nt; struct smbcli_state *cli_dos; @@ -334,18 +335,18 @@ BOOL torture_samba3_badpath(struct torture_context *torture) char *fpath1; int fnum; NTSTATUS status; - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx; - BOOL nt_status_support; + bool nt_status_support; if (!(mem_ctx = talloc_init("torture_samba3_badpath"))) { d_printf("talloc_init failed\n"); - return False; + return false; } - nt_status_support = lp_nt_status_support(); + nt_status_support = lp_nt_status_support(global_loadparm); - if (!lp_set_cmdline("nt status support", "yes")) { + if (!lp_set_cmdline(global_loadparm, "nt status support", "yes")) { printf("Could not set 'nt status support = yes'\n"); goto fail; } @@ -354,7 +355,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture) goto fail; } - if (!lp_set_cmdline("nt status support", "no")) { + if (!lp_set_cmdline(global_loadparm, "nt status support", "no")) { printf("Could not set 'nt status support = yes'\n"); goto fail; } @@ -363,7 +364,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture) goto fail; } - if (!lp_set_cmdline("nt status support", + if (!lp_set_cmdline(global_loadparm, "nt status support", nt_status_support ? "yes":"no")) { printf("Could not reset 'nt status support = yes'"); goto fail; @@ -374,7 +375,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture) status = smbcli_mkdir(cli_nt->tree, dirname); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_mkdir failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } @@ -585,7 +586,7 @@ BOOL torture_samba3_badpath(struct torture_context *torture) goto done; fail: - ret = False; + ret = false; done: if (cli_nt != NULL) { @@ -607,7 +608,7 @@ static void count_fn(struct clilist_file_info *info, const char *name, *counter += 1; } -BOOL torture_samba3_caseinsensitive(struct torture_context *torture) +bool torture_samba3_caseinsensitive(struct torture_context *torture) { struct smbcli_state *cli; TALLOC_CTX *mem_ctx; @@ -618,11 +619,11 @@ BOOL torture_samba3_caseinsensitive(struct torture_context *torture) char *fpath; int fnum; int counter = 0; - BOOL ret = True; + bool ret = true; if (!(mem_ctx = talloc_init("torture_samba3_caseinsensitive"))) { d_printf("talloc_init failed\n"); - return False; + return false; } if (!torture_open_connection(&cli, 0)) { @@ -655,11 +656,11 @@ BOOL torture_samba3_caseinsensitive(struct torture_context *torture) count_fn, (void *)&counter); if (counter == 3) { - ret = True; + ret = true; } else { d_fprintf(stderr, "expected 3 entries, got %d\n", counter); - ret = False; + ret = false; } done: @@ -672,11 +673,11 @@ BOOL torture_samba3_caseinsensitive(struct torture_context *torture) * on an underlying file */ -BOOL torture_samba3_posixtimedlock(struct torture_context *tctx) +bool torture_samba3_posixtimedlock(struct torture_context *tctx) { struct smbcli_state *cli; NTSTATUS status; - BOOL ret = True; + bool ret = true; const char *dirname = "posixlock"; const char *fname = "locked"; const char *fpath; @@ -692,7 +693,7 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx) struct smbcli_request *req; if (!torture_open_connection(&cli, 0)) { - ret = False; + ret = false; goto done; } @@ -702,33 +703,33 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx) if (!NT_STATUS_IS_OK(status)) { torture_warning(tctx, "smbcli_mkdir failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto done; } if (!(fpath = talloc_asprintf(tctx, "%s\\%s", dirname, fname))) { torture_warning(tctx, "talloc failed\n"); - ret = False; + ret = false; goto done; } fnum = smbcli_open(cli->tree, fpath, O_RDWR | O_CREAT, DENY_NONE); if (fnum == -1) { torture_warning(tctx, "Could not create file %s: %s\n", fpath, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } if (!(localdir = torture_setting_string(tctx, "localdir", NULL))) { torture_warning(tctx, "Need 'localdir' setting\n"); - ret = False; + ret = false; goto done; } if (!(localname = talloc_asprintf(tctx, "%s/%s/%s", localdir, dirname, fname))) { torture_warning(tctx, "talloc failed\n"); - ret = False; + ret = false; goto done; } @@ -750,7 +751,7 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx) if (fcntl(fd, F_SETLK, &posix_lock) == -1) { torture_warning(tctx, "fcntl failed: %s\n", strerror(errno)); - ret = False; + ret = false; goto done; } @@ -773,7 +774,7 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx) status = smb_raw_lock(cli->tree, &io); - ret = True; + ret = true; CHECK_STATUS(status, NT_STATUS_FILE_LOCK_CONFLICT); if (!ret) { @@ -790,7 +791,7 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx) req = smb_raw_lock_send(cli->tree, &io); if (req == NULL) { torture_warning(tctx, "smb_raw_lock_send failed\n"); - ret = False; + ret = false; goto done; } @@ -816,3 +817,73 @@ BOOL torture_samba3_posixtimedlock(struct torture_context *tctx) smbcli_deltree(cli->tree, dirname); return ret; } + +bool torture_samba3_rootdirfid(struct torture_context *tctx) +{ + struct smbcli_state *cli; + NTSTATUS status; + uint16_t dnum; + union smb_open io; + const char *fname = "testfile"; + bool ret = false; + + if (!torture_open_connection(&cli, 0)) { + ret = false; + goto done; + } + + smbcli_unlink(cli->tree, fname); + + io.generic.level = RAW_OPEN_NTCREATEX; + io.ntcreatex.in.flags = NTCREATEX_FLAGS_EXTENDED; + io.ntcreatex.in.root_fid = 0; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.access_mask = + SEC_STD_SYNCHRONIZE | SEC_FILE_EXECUTE; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_DIRECTORY; + io.ntcreatex.in.share_access = + NTCREATEX_SHARE_ACCESS_READ + | NTCREATEX_SHARE_ACCESS_READ; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN; + io.ntcreatex.in.create_options = 0; + io.ntcreatex.in.fname = "\\"; + status = smb_raw_open(cli->tree, tctx, &io); + if (!NT_STATUS_IS_OK(status)) { + d_printf("smb_open on the directory failed: %s\n", + nt_errstr(status)); + ret = false; + goto done; + } + dnum = io.ntcreatex.out.file.fnum; + + io.ntcreatex.in.flags = + NTCREATEX_FLAGS_REQUEST_OPLOCK + | NTCREATEX_FLAGS_REQUEST_BATCH_OPLOCK; + io.ntcreatex.in.root_fid = dnum; + io.ntcreatex.in.security_flags = 0; + io.ntcreatex.in.open_disposition = NTCREATEX_DISP_OVERWRITE_IF; + io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; + io.ntcreatex.in.alloc_size = 0; + io.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL; + io.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_NONE; + io.ntcreatex.in.create_options = 0; + io.ntcreatex.in.fname = fname; + + status = smb_raw_open(cli->tree, tctx, &io); + if (!NT_STATUS_IS_OK(status)) { + d_printf("smb_open on the file %s failed: %s\n", + fname, nt_errstr(status)); + ret = false; + goto done; + } + + smbcli_close(cli->tree, io.ntcreatex.out.file.fnum); + smbcli_close(cli->tree, dnum); + smbcli_unlink(cli->tree, fname); + + ret = true; + done: + return ret; +} + diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c index 986da474d0..0242b9c545 100644 --- a/source4/torture/raw/search.c +++ b/source4/torture/raw/search.c @@ -30,13 +30,13 @@ /* callback function for single_search */ -static BOOL single_search_callback(void *private, const union smb_search_data *file) +static bool single_search_callback(void *private, const union smb_search_data *file) { - union smb_search_data *data = private; + union smb_search_data *data = (union smb_search_data *)private; *data = *file; - return True; + return true; } /* @@ -231,10 +231,10 @@ static union smb_search_data *find(const char *name) /* basic testing of all RAW_SEARCH_* calls using a single file */ -static BOOL test_one_file(struct torture_context *tctx, - struct smbcli_state *cli) +static bool test_one_file(struct torture_context *tctx, + struct smbcli_state *cli) { - BOOL ret = True; + bool ret = true; int fnum; const char *fname = "\\torture_search.txt"; const char *fname2 = "\\torture_search-NOTEXIST.txt"; @@ -243,12 +243,10 @@ static BOOL test_one_file(struct torture_context *tctx, union smb_fileinfo all_info, alt_info, name_info, internal_info; union smb_search_data *s; - printf("Testing one file searches\n"); - fnum = create_complex_file(cli, tctx, fname); if (fnum == -1) { printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -257,7 +255,7 @@ static BOOL test_one_file(struct torture_context *tctx, NTSTATUS expected_status; uint32_t cap = cli->transport->negotiate.capabilities; - printf("testing %s\n", levels[i].name); + torture_comment(tctx, "testing %s\n", levels[i].name); levels[i].status = torture_single_search(cli, tctx, fname, levels[i].level, @@ -276,7 +274,7 @@ static BOOL test_one_file(struct torture_context *tctx, printf("search level %s(%d) failed - %s\n", levels[i].name, (int)levels[i].level, nt_errstr(levels[i].status)); - ret = False; + ret = false; continue; } @@ -297,7 +295,7 @@ static BOOL test_one_file(struct torture_context *tctx, levels[i].name, (int)levels[i].level, nt_errstr(expected_status), nt_errstr(status)); - ret = False; + ret = false; } } @@ -305,38 +303,22 @@ static BOOL test_one_file(struct torture_context *tctx, all_info.generic.level = RAW_FILEINFO_ALL_INFO; all_info.generic.in.file.path = fname; status = smb_raw_pathinfo(cli->tree, tctx, &all_info); - if (!NT_STATUS_IS_OK(status)) { - printf("RAW_FILEINFO_ALL_INFO failed - %s\n", nt_errstr(status)); - ret = False; - goto done; - } + torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_ALL_INFO failed"); alt_info.generic.level = RAW_FILEINFO_ALT_NAME_INFO; alt_info.generic.in.file.path = fname; status = smb_raw_pathinfo(cli->tree, tctx, &alt_info); - if (!NT_STATUS_IS_OK(status)) { - printf("RAW_FILEINFO_ALT_NAME_INFO failed - %s\n", nt_errstr(status)); - ret = False; - goto done; - } + torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_ALT_NAME_INFO failed"); internal_info.generic.level = RAW_FILEINFO_INTERNAL_INFORMATION; internal_info.generic.in.file.path = fname; status = smb_raw_pathinfo(cli->tree, tctx, &internal_info); - if (!NT_STATUS_IS_OK(status)) { - printf("RAW_FILEINFO_INTERNAL_INFORMATION failed - %s\n", nt_errstr(status)); - ret = False; - goto done; - } + torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_INTERNAL_INFORMATION failed"); name_info.generic.level = RAW_FILEINFO_NAME_INFO; name_info.generic.in.file.path = fname; status = smb_raw_pathinfo(cli->tree, tctx, &name_info); - if (!NT_STATUS_IS_OK(status)) { - printf("RAW_FILEINFO_NAME_INFO failed - %s\n", nt_errstr(status)); - ret = False; - goto done; - } + torture_assert_ntstatus_ok(tctx, status, "RAW_FILEINFO_NAME_INFO failed"); #define CHECK_VAL(name, sname1, field1, v, sname2, field2) do { \ s = find(name); \ @@ -346,7 +328,7 @@ static BOOL test_one_file(struct torture_context *tctx, __location__, \ #sname1, #field1, (int)s->sname1.field1, \ #sname2, #field2, (int)v.sname2.out.field2); \ - ret = False; \ + ret = false; \ } \ }} while (0) @@ -358,7 +340,7 @@ static BOOL test_one_file(struct torture_context *tctx, __location__, \ #sname1, #field1, timestring(tctx, s->sname1.field1), \ #sname2, #field2, nt_time_string(tctx, v.sname2.out.field2)); \ - ret = False; \ + ret = false; \ } \ }} while (0) @@ -370,7 +352,7 @@ static BOOL test_one_file(struct torture_context *tctx, __location__, \ #sname1, #field1, nt_time_string(tctx, s->sname1.field1), \ #sname2, #field2, nt_time_string(tctx, v.sname2.out.field2)); \ - ret = False; \ + ret = false; \ } \ }} while (0) @@ -382,7 +364,7 @@ static BOOL test_one_file(struct torture_context *tctx, __location__, \ #sname1, #field1, s->sname1.field1, \ #sname2, #field2, v.sname2.out.field2.s); \ - ret = False; \ + ret = false; \ } \ }} while (0) @@ -396,7 +378,7 @@ static BOOL test_one_file(struct torture_context *tctx, __location__, \ #sname1, #field1, s->sname1.field1.s, \ #sname2, #field2, v.sname2.out.field2.s); \ - ret = False; \ + ret = false; \ } \ }} while (0) @@ -410,7 +392,7 @@ static BOOL test_one_file(struct torture_context *tctx, __location__, \ #sname1, #field1, s->sname1.field1.s, \ fname); \ - ret = False; \ + ret = false; \ } \ }} while (0) @@ -423,7 +405,7 @@ static BOOL test_one_file(struct torture_context *tctx, __location__, \ #sname1, #field1, s->sname1.field1, \ fname); \ - ret = False; \ + ret = false; \ } \ }} while (0) @@ -527,9 +509,9 @@ struct multiple_result { /* callback function for multiple_search */ -static BOOL multiple_search_callback(void *private, const union smb_search_data *file) +static bool multiple_search_callback(void *private, const union smb_search_data *file) { - struct multiple_result *data = private; + struct multiple_result *data = (struct multiple_result *)private; data->count++; @@ -540,7 +522,7 @@ static BOOL multiple_search_callback(void *private, const union smb_search_data data->list[data->count-1] = *file; - return True; + return true; } enum continue_type {CONT_FLAGS, CONT_NAME, CONT_RESUME_KEY}; @@ -559,7 +541,7 @@ static NTSTATUS multiple_search(struct smbcli_state *cli, union smb_search_next io2; NTSTATUS status; const int per_search = 100; - struct multiple_result *result = data; + struct multiple_result *result = (struct multiple_result *)data; if (data_level == RAW_SEARCH_DATA_SEARCH) { io.search_first.level = RAW_SEARCH_SEARCH; @@ -640,28 +622,11 @@ static NTSTATUS multiple_search(struct smbcli_state *cli, return status; } -#define CHECK_STATUS(status, correct) do { \ - if (!NT_STATUS_EQUAL(status, correct)) { \ - printf("(%s) Incorrect status %s - should be %s\n", \ - __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ - goto done; \ - }} while (0) +#define CHECK_STATUS(status, correct) torture_assert_ntstatus_equal(tctx, status, correct, "incorrect status") -#define CHECK_VALUE(v, correct) do { \ - if ((v) != (correct)) { \ - printf("(%s) Incorrect value %s=%ld - should be %ld\n", \ - __location__, #v, (long)v, (long)correct); \ - ret = False; \ - goto done; \ - }} while (0) +#define CHECK_VALUE(v, correct) torture_assert_int_equal(tctx, (v), (correct), "incorrect value"); -#define CHECK_STRING(v, correct) do { \ - if (strcasecmp_m(v, correct) != 0) { \ - printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \ - __location__, #v, v, correct); \ - ret = False; \ - }} while (0) +#define CHECK_STRING(v, correct) torture_assert_casestr_equal(tctx, v, correct, "incorrect value"); static enum smb_search_data_level compare_data_level; @@ -688,12 +653,12 @@ static int search_compare(union smb_search_data *d1, union smb_search_data *d2) basic testing of search calls using many files */ static bool test_many_files(struct torture_context *tctx, - struct smbcli_state *cli) + struct smbcli_state *cli) { const int num_files = 700; int i, fnum, t; char *fname; - BOOL ret = True; + bool ret = true; NTSTATUS status; struct multiple_result result; struct { @@ -727,19 +692,15 @@ static bool test_many_files(struct torture_context *tctx, }; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } - printf("Testing with %d files\n", num_files); + torture_comment(tctx, "Testing with %d files\n", num_files); for (i=0;i<num_files;i++) { fname = talloc_asprintf(cli, BASEDIR "\\t%03d-%d.txt", i, i); fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE); - if (fnum == -1) { - printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; - goto done; - } + torture_assert(tctx, fnum != -1, "Failed to create"); talloc_free(fname); smbcli_close(cli->tree, fnum); } @@ -749,20 +710,15 @@ static bool test_many_files(struct torture_context *tctx, ZERO_STRUCT(result); result.tctx = talloc_new(tctx); - printf("Continue %s via %s\n", search_types[t].name, search_types[t].cont_name); + torture_comment(tctx, + "Continue %s via %s\n", search_types[t].name, search_types[t].cont_name); status = multiple_search(cli, tctx, BASEDIR "\\*.*", search_types[t].data_level, search_types[t].cont_type, &result); - if (!NT_STATUS_IS_OK(status)) { - printf("search type %s failed - %s\n", - search_types[t].name, - nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "search failed"); CHECK_VALUE(result.count, num_files); compare_data_level = search_types[t].data_level; @@ -780,17 +736,12 @@ static bool test_many_files(struct torture_context *tctx, } s = extract_name(&result.list[i], level, compare_data_level); fname = talloc_asprintf(cli, "t%03d-%d.txt", i, i); - if (strcmp(fname, s)) { - printf("Incorrect name %s at entry %d\n", s, i); - ret = False; - break; - } + torture_assert_str_equal(tctx, fname, s, "Incorrect name"); talloc_free(fname); } talloc_free(result.tctx); } -done: smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); @@ -800,7 +751,7 @@ done: /* check a individual file result */ -static BOOL check_result(struct multiple_result *result, const char *name, BOOL exist, uint32_t attrib) +static bool check_result(struct multiple_result *result, const char *name, bool exist, uint32_t attrib) { int i; for (i=0;i<result->count;i++) { @@ -810,24 +761,24 @@ static BOOL check_result(struct multiple_result *result, const char *name, BOOL if (exist) { printf("failed: '%s' should exist with attribute %s\n", name, attrib_string(result->list, attrib)); - return False; + return false; } - return True; + return true; } if (!exist) { printf("failed: '%s' should NOT exist (has attribute %s)\n", name, attrib_string(result->list, result->list[i].both_directory_info.attrib)); - return False; + return false; } if ((result->list[i].both_directory_info.attrib&0xFFF) != attrib) { printf("failed: '%s' should have attribute 0x%x (has 0x%x)\n", name, attrib, result->list[i].both_directory_info.attrib); - return False; + return false; } - return True; + return true; } /* @@ -839,7 +790,7 @@ static bool test_modify_search(struct torture_context *tctx, const int num_files = 20; int i, fnum; char *fname; - BOOL ret = True; + bool ret = true; NTSTATUS status; struct multiple_result result; union smb_search_first io; @@ -847,7 +798,7 @@ static bool test_modify_search(struct torture_context *tctx, union smb_setfileinfo sfinfo; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Creating %d files\n", num_files); @@ -857,7 +808,7 @@ static bool test_modify_search(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } talloc_free(fname); @@ -925,16 +876,16 @@ static bool test_modify_search(struct torture_context *tctx, CHECK_STATUS(status, NT_STATUS_OK); CHECK_VALUE(result.count, 20); - ret &= check_result(&result, "t009-9.txt", True, FILE_ATTRIBUTE_ARCHIVE); - ret &= check_result(&result, "t014-14.txt", False, 0); - ret &= check_result(&result, "t015-15.txt", False, 0); - ret &= check_result(&result, "t016-16.txt", True, FILE_ATTRIBUTE_NORMAL); - ret &= check_result(&result, "t017-17.txt", False, 0); - ret &= check_result(&result, "t018-18.txt", True, FILE_ATTRIBUTE_ARCHIVE); - ret &= check_result(&result, "t019-19.txt", True, FILE_ATTRIBUTE_ARCHIVE); - ret &= check_result(&result, "T013-13.txt.2", True, FILE_ATTRIBUTE_ARCHIVE); - ret &= check_result(&result, "T003-3.txt.2", False, 0); - ret &= check_result(&result, "T013-13.txt.3", True, FILE_ATTRIBUTE_ARCHIVE); + ret &= check_result(&result, "t009-9.txt", true, FILE_ATTRIBUTE_ARCHIVE); + ret &= check_result(&result, "t014-14.txt", false, 0); + ret &= check_result(&result, "t015-15.txt", false, 0); + ret &= check_result(&result, "t016-16.txt", true, FILE_ATTRIBUTE_NORMAL); + ret &= check_result(&result, "t017-17.txt", false, 0); + ret &= check_result(&result, "t018-18.txt", true, FILE_ATTRIBUTE_ARCHIVE); + ret &= check_result(&result, "t019-19.txt", true, FILE_ATTRIBUTE_ARCHIVE); + ret &= check_result(&result, "T013-13.txt.2", true, FILE_ATTRIBUTE_ARCHIVE); + ret &= check_result(&result, "T003-3.txt.2", false, 0); + ret &= check_result(&result, "T013-13.txt.3", true, FILE_ATTRIBUTE_ARCHIVE); if (!ret) { for (i=0;i<result.count;i++) { @@ -961,12 +912,12 @@ static bool test_sorted(struct torture_context *tctx, struct smbcli_state *cli) const int num_files = 700; int i, fnum; char *fname; - BOOL ret = True; + bool ret = true; NTSTATUS status; struct multiple_result result; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Creating %d files\n", num_files); @@ -976,7 +927,7 @@ static bool test_sorted(struct torture_context *tctx, struct smbcli_state *cli) fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } talloc_free(fname); @@ -1025,12 +976,12 @@ static bool test_many_dirs(struct torture_context *tctx, const int num_dirs = 20; int i, fnum, n; char *fname, *dname; - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_search_data *file, *file2, *file3; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Creating %d dirs\n", num_dirs); @@ -1041,7 +992,7 @@ static bool test_many_dirs(struct torture_context *tctx, if (!NT_STATUS_IS_OK(status)) { printf("(%s) Failed to create %s - %s\n", __location__, dname, nt_errstr(status)); - ret = False; + ret = false; goto done; } @@ -1051,7 +1002,7 @@ static bool test_many_dirs(struct torture_context *tctx, if (fnum == -1) { printf("(%s) Failed to create %s - %s\n", __location__, fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } talloc_free(fname); @@ -1083,14 +1034,14 @@ static bool test_many_dirs(struct torture_context *tctx, if (io.search_first.out.count != 1) { printf("(%s) search first gave %d entries for dir %d - %s\n", __location__, io.search_first.out.count, i, nt_errstr(status)); - ret = False; + ret = false; goto done; } CHECK_STATUS(status, NT_STATUS_OK); if (strncasecmp(file[i].search.name, fname, strlen(fname)) != 0) { printf("(%s) incorrect name '%s' expected '%s'[12].txt\n", __location__, file[i].search.name, fname); - ret = False; + ret = false; goto done; } @@ -1116,14 +1067,14 @@ static bool test_many_dirs(struct torture_context *tctx, if (io2.search_next.out.count != 1) { printf("(%s) search next gave %d entries for dir %d - %s\n", __location__, io2.search_next.out.count, i, nt_errstr(status)); - ret = False; + ret = false; goto done; } CHECK_STATUS(status, NT_STATUS_OK); if (strncasecmp(file2[i].search.name, fname, strlen(fname)) != 0) { printf("(%s) incorrect name '%s' expected '%s'[12].txt\n", __location__, file2[i].search.name, fname); - ret = False; + ret = false; goto done; } @@ -1149,7 +1100,7 @@ static bool test_many_dirs(struct torture_context *tctx, if (io2.search_next.out.count != 1) { printf("(%s) search next gave %d entries for dir %d - %s\n", __location__, io2.search_next.out.count, i, nt_errstr(status)); - ret = False; + ret = false; goto done; } CHECK_STATUS(status, NT_STATUS_OK); @@ -1157,14 +1108,14 @@ static bool test_many_dirs(struct torture_context *tctx, if (strncasecmp(file3[i].search.name, file2[i].search.name, 3) != 0) { printf("(%s) incorrect name '%s' on rewind at dir %d\n", __location__, file2[i].search.name, i); - ret = False; + ret = false; goto done; } if (strcmp(file3[i].search.name, file2[i].search.name) != 0) { printf("(%s) server did not rewind - got '%s' expected '%s'\n", __location__, file3[i].search.name, file2[i].search.name); - ret = False; + ret = false; goto done; } @@ -1191,14 +1142,14 @@ static bool test_os2_delete(struct torture_context *tctx, int total_deleted = 0; int i, fnum; char *fname; - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_search_first io; union smb_search_next io2; struct multiple_result result; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing OS/2 style delete on %d files\n", num_files); @@ -1208,7 +1159,7 @@ static bool test_os2_delete(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_CREAT|O_RDWR, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } talloc_free(fname); @@ -1276,7 +1227,7 @@ static bool test_os2_delete(struct torture_context *tctx, if (total_deleted != num_files) { printf("error: deleted %d - expected to delete %d\n", total_deleted, num_files); - ret = False; + ret = false; } done: @@ -1299,7 +1250,7 @@ static bool test_ea_list(struct torture_context *tctx, struct smbcli_state *cli) { int fnum; - BOOL ret = True; + bool ret = true; NTSTATUS status; union smb_search_first io; union smb_search_next nxt; @@ -1307,7 +1258,7 @@ static bool test_ea_list(struct torture_context *tctx, union smb_setfileinfo setfile; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_SEARCH_EA_LIST level\n"); @@ -1402,7 +1353,6 @@ static bool test_ea_list(struct torture_context *tctx, CHECK_STRING(result.list[2].ea_list.eas.eas[1].name.s, "THIRD EA"); CHECK_VALUE(result.list[2].ea_list.eas.eas[1].value.length, 0); -done: smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); @@ -1418,7 +1368,7 @@ struct torture_suite *torture_raw_search(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "SEARCH"); - torture_suite_add_1smb_test(suite, "one file", test_one_file); + torture_suite_add_1smb_test(suite, "one file search", test_one_file); torture_suite_add_1smb_test(suite, "many files", test_many_files); torture_suite_add_1smb_test(suite, "sorted", test_sorted); torture_suite_add_1smb_test(suite, "modify search", test_modify_search); diff --git a/source4/torture/raw/seek.c b/source4/torture/raw/seek.c index f5413d8b1d..3ba022feef 100644 --- a/source4/torture/raw/seek.c +++ b/source4/torture/raw/seek.c @@ -28,7 +28,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%d) Incorrect status %s - should be %s\n", \ __LINE__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -36,7 +36,7 @@ if ((v) != (correct)) { \ printf("(%d) Incorrect value %s=%d - should be %d\n", \ __LINE__, #v, (int)v, (int)correct); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -45,25 +45,25 @@ /* test seek ops */ -static BOOL test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { union smb_seek io; union smb_fileinfo finfo; union smb_setfileinfo sfinfo; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum, fnum2; const char *fname = BASEDIR "\\test.txt"; uint8_t c[2]; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_TRUNC, DENY_NONE); if (fnum == -1) { printf("Failed to open test.txt - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -142,7 +142,7 @@ static BOOL test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) ZERO_STRUCT(c); if (smbcli_write(cli->tree, fnum, 0, c, 0, 2) != 2) { printf("Write failed - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -162,7 +162,7 @@ static BOOL test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (smbcli_read(cli->tree, fnum, c, 0, 1) != 1) { printf("Read failed - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -181,7 +181,7 @@ static BOOL test_seek(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE); if (fnum2 == -1) { printf("2nd open failed - %s\n", smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } sfinfo.generic.level = RAW_SFILEINFO_POSITION_INFORMATION; diff --git a/source4/torture/raw/setfileinfo.c b/source4/torture/raw/setfileinfo.c index b06a04753f..e58b3fd760 100644 --- a/source4/torture/raw/setfileinfo.c +++ b/source4/torture/raw/setfileinfo.c @@ -23,6 +23,7 @@ #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" #include "torture/util.h" +#include "torture/raw/proto.h" #define BASEDIR "\\testsfileinfo" @@ -31,10 +32,10 @@ for consistency between the calls. */ bool torture_raw_sfileinfo(struct torture_context *torture, - struct smbcli_state *cli) + struct smbcli_state *cli) { - BOOL ret = True; - int fnum_saved, d_fnum, fnum2, fnum = -1; + bool ret = true; + int fnum = -1; char *fnum_fname; char *fnum_fname_new; char *path_fname; @@ -44,7 +45,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture, NTSTATUS status, status2; const char *call_name; time_t basetime = (time(NULL) - 86400) & ~1; - BOOL check_fnum; + bool check_fnum; int n = time(NULL) % 100; asprintf(&path_fname, BASEDIR "\\fname_test_%d.txt", n); @@ -53,7 +54,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture, asprintf(&fnum_fname_new, BASEDIR "\\fnum_test_new_%d.txt", n); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } #define RECREATE_FILE(fname) do { \ @@ -62,7 +63,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture, if (fnum == -1) { \ printf("(%s) ERROR: open of %s failed (%s)\n", \ __location__, fname, smbcli_errstr(cli->tree)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -75,7 +76,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture, RECREATE_BOTH; #define CHECK_CALL_FNUM(call, rightstatus) do { \ - check_fnum = True; \ + check_fnum = true; \ call_name = #call; \ sfinfo.generic.level = RAW_SFILEINFO_ ## call; \ sfinfo.generic.in.file.fnum = fnum; \ @@ -83,18 +84,18 @@ bool torture_raw_sfileinfo(struct torture_context *torture, if (!NT_STATUS_EQUAL(status, rightstatus)) { \ printf("(%s) %s - %s (should be %s)\n", __location__, #call, \ nt_errstr(status), nt_errstr(rightstatus)); \ - ret = False; \ + ret = false; \ } \ finfo1.generic.level = RAW_FILEINFO_ALL_INFO; \ finfo1.generic.in.file.fnum = fnum; \ status2 = smb_raw_fileinfo(cli->tree, torture, &finfo1); \ if (!NT_STATUS_IS_OK(status2)) { \ printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status)); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_CALL_PATH(call, rightstatus) do { \ - check_fnum = False; \ + check_fnum = false; \ call_name = #call; \ sfinfo.generic.level = RAW_SFILEINFO_ ## call; \ sfinfo.generic.in.file.path = path_fname; \ @@ -106,7 +107,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture, if (!NT_STATUS_EQUAL(status, rightstatus)) { \ printf("(%s) %s - %s (should be %s)\n", __location__, #call, \ nt_errstr(status), nt_errstr(rightstatus)); \ - ret = False; \ + ret = false; \ } \ finfo1.generic.level = RAW_FILEINFO_ALL_INFO; \ finfo1.generic.in.file.path = path_fname; \ @@ -117,7 +118,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture, } \ if (!NT_STATUS_IS_OK(status2)) { \ printf("(%s) %s pathinfo - %s\n", __location__, #call, nt_errstr(status2)); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK1(call) \ @@ -136,7 +137,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture, } \ if (!NT_STATUS_IS_OK(status2)) { \ printf("%s - %s\n", #call, nt_errstr(status2)); \ - ret = False; \ + ret = false; \ } \ }} while (0) @@ -147,7 +148,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture, call_name, #stype, #field, \ (uint_t)value, (uint_t)finfo2.stype.out.field); \ dump_all_info(torture, &finfo1); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_TIME(call, stype, field, value) do { \ @@ -160,7 +161,7 @@ bool torture_raw_sfileinfo(struct torture_context *torture, printf("\t%s", timestring(torture, value)); \ printf("\t%s\n", nt_time_string(torture, finfo2.stype.out.field)); \ dump_all_info(torture, &finfo1); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_STR(call, stype, field, value) do { \ @@ -171,14 +172,14 @@ bool torture_raw_sfileinfo(struct torture_context *torture, value, \ finfo2.stype.out.field); \ dump_all_info(torture, &finfo1); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_STATUS(status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -446,7 +447,7 @@ done: bool torture_raw_sfileinfo_rename(struct torture_context *torture, struct smbcli_state *cli) { - BOOL ret = True; + bool ret = true; int fnum_saved, d_fnum, fnum2, fnum = -1; char *fnum_fname; char *fnum_fname_new; @@ -456,7 +457,7 @@ bool torture_raw_sfileinfo_rename(struct torture_context *torture, union smb_setfileinfo sfinfo; NTSTATUS status, status2; const char *call_name; - BOOL check_fnum; + bool check_fnum; int n = time(NULL) % 100; asprintf(&path_fname, BASEDIR "\\fname_test_%d.txt", n); @@ -465,7 +466,7 @@ bool torture_raw_sfileinfo_rename(struct torture_context *torture, asprintf(&fnum_fname_new, BASEDIR "\\fnum_test_new_%d.txt", n); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } RECREATE_BOTH; @@ -596,5 +597,5 @@ bool torture_raw_sfileinfo_bug(struct torture_context *torture, printf("now try and delete %s\n", fname); - return True; + return true; } diff --git a/source4/torture/raw/streams.c b/source4/torture/raw/streams.c index 24428efcf7..14d674e482 100644 --- a/source4/torture/raw/streams.c +++ b/source4/torture/raw/streams.c @@ -32,7 +32,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -40,13 +40,13 @@ if ((v) != (correct)) { \ printf("(%s) Incorrect value %s=%d - should be %d\n", \ __location__, #v, (int)v, (int)correct); \ - ret = False; \ + ret = false; \ }} while (0) /* check that a stream has the right contents */ -static BOOL check_stream(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, +static bool check_stream(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, const char *fname, const char *sname, const char *value) { @@ -62,45 +62,45 @@ static BOOL check_stream(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, if (value == NULL) { if (fnum != -1) { printf("should have failed stream open of %s\n", full_name); - return False; + return false; } - return True; + return true; } if (fnum == -1) { printf("Failed to open stream '%s' - %s\n", full_name, smbcli_errstr(cli->tree)); - return False; + return false; } - buf = talloc_size(mem_ctx, strlen(value)+11); + buf = talloc_array(mem_ctx, uint8_t, strlen(value)+11); ret = smbcli_read(cli->tree, fnum, buf, 0, strlen(value)+11); if (ret != strlen(value)) { printf("Failed to read %lu bytes from stream '%s' - got %d\n", (long)strlen(value), full_name, (int)ret); - return False; + return false; } if (memcmp(buf, value, strlen(value)) != 0) { printf("Bad data in stream\n"); - return False; + return false; } smbcli_close(cli->tree, fnum); - return True; + return true; } /* test basic io on streams */ -static BOOL test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static bool test_stream_io(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) { NTSTATUS status; union smb_open io; const char *fname = BASEDIR "\\stream.txt"; const char *sname1, *sname2; - BOOL ret = True; + bool ret = true; int fnum = -1; ssize_t retsize; @@ -214,12 +214,12 @@ done: basic testing of streams calls */ bool torture_raw_streams(struct torture_context *torture, - struct smbcli_state *cli) + struct smbcli_state *cli) { - BOOL ret = True; + bool ret = true; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } ret &= test_stream_io(cli, torture); diff --git a/source4/torture/raw/unlink.c b/source4/torture/raw/unlink.c index c307b14e08..b9043a5899 100644 --- a/source4/torture/raw/unlink.c +++ b/source4/torture/raw/unlink.c @@ -23,12 +23,13 @@ #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" #include "torture/util.h" +#include "param/param.h" #define CHECK_STATUS(status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -41,11 +42,11 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli) { union smb_unlink io; NTSTATUS status; - BOOL ret = True; + bool ret = true; const char *fname = BASEDIR "\\test.txt"; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Trying non-existant file\n"); @@ -128,7 +129,7 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli) io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY; status = smb_raw_unlink(cli->tree, &io); - if (lp_parm_bool(-1, "torture", "samba3", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { /* * In Samba3 we gave up upon getting the error codes in * wildcard unlink correct. Trying gentest showed that this is @@ -156,7 +157,7 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli) io.unlink.in.pattern = BASEDIR "\\t*"; io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY; status = smb_raw_unlink(cli->tree, &io); - if (lp_parm_bool(-1, "torture", "samba3", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); } else { @@ -168,7 +169,7 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli) io.unlink.in.pattern = BASEDIR "\\*.dat"; io.unlink.in.attrib = FILE_ATTRIBUTE_DIRECTORY; status = smb_raw_unlink(cli->tree, &io); - if (lp_parm_bool(-1, "torture", "samba3", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_INVALID); } else { @@ -178,7 +179,7 @@ static bool test_unlink(struct torture_context *tctx, struct smbcli_state *cli) io.unlink.in.pattern = BASEDIR "\\*.tx?"; io.unlink.in.attrib = 0; status = smb_raw_unlink(cli->tree, &io); - if (lp_parm_bool(-1, "torture", "samba3", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { CHECK_STATUS(status, NT_STATUS_NO_SUCH_FILE); } else { @@ -206,7 +207,7 @@ static bool test_delete_on_close(struct torture_context *tctx, union smb_unlink io; struct smb_rmdir dio; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum, fnum2; const char *fname = BASEDIR "\\test.txt"; const char *dname = BASEDIR "\\test.dir"; @@ -214,7 +215,7 @@ static bool test_delete_on_close(struct torture_context *tctx, union smb_setfileinfo sfinfo; if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } dio.in.path = dname; @@ -281,7 +282,7 @@ static bool test_delete_on_close(struct torture_context *tctx, CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_NOT_FOUND); - if (!lp_parm_bool(-1, "torture", "samba3", False)) { + if (!lp_parm_bool(global_loadparm, NULL, "torture", "samba3", false)) { /* * Known deficiency, also skipped in base-delete. @@ -439,8 +440,7 @@ done: */ struct torture_suite *torture_raw_unlink(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(mem_ctx, - "UNLINK"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "UNLINK"); torture_suite_add_1smb_test(suite, "unlink", test_unlink); torture_suite_add_1smb_test(suite, "delete_on_close", test_delete_on_close); diff --git a/source4/torture/raw/write.c b/source4/torture/raw/write.c index b704a19ed6..98a0dde8c7 100644 --- a/source4/torture/raw/write.c +++ b/source4/torture/raw/write.c @@ -30,7 +30,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -38,13 +38,13 @@ if ((v) != (correct)) { \ printf("(%s) Incorrect value %s=%d - should be %d\n", \ __location__, #v, v, correct); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) #define CHECK_BUFFER(buf, seed, len) do { \ if (!check_buffer(buf, seed, len, __location__)) { \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -57,7 +57,7 @@ printf("(%s) wrong value for field %s %.0f - %.0f\n", \ __location__, #field, (double)v, (double)finfo.all_info.out.field); \ dump_all_info(tctx, &finfo); \ - ret = False; \ + ret = false; \ }} while (0) @@ -77,7 +77,7 @@ static void setup_buffer(uint8_t *buf, uint_t seed, int len) /* check a random buffer based on a seed */ -static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, const char *location) +static bool check_buffer(uint8_t *buf, uint_t seed, int len, const char *location) { int i; srandom(seed); @@ -86,10 +86,10 @@ static BOOL check_buffer(uint8_t *buf, uint_t seed, int len, const char *locatio if (buf[i] != v) { printf("Buffer incorrect at %s! ofs=%d buf=0x%x correct=0x%x\n", location, i, buf[i], v); - return False; + return false; } } - return True; + return true; } /* @@ -100,7 +100,7 @@ static bool test_write(struct torture_context *tctx, { union smb_write io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; uint8_t *buf; const int maxsize = 90000; @@ -108,10 +108,10 @@ static bool test_write(struct torture_context *tctx, uint_t seed = time(NULL); union smb_fileinfo finfo; - buf = talloc_zero_size(tctx, maxsize); + buf = talloc_zero_array(tctx, uint8_t, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_WRITE_WRITE\n"); @@ -120,7 +120,7 @@ static bool test_write(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -147,7 +147,7 @@ static bool test_write(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf+4, seed, 9); @@ -166,7 +166,7 @@ static bool test_write(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf, seed, 4000); @@ -207,7 +207,7 @@ static bool test_write(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, io.write.in.offset, 4000) != 4000) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf, seed, 4000); @@ -228,7 +228,7 @@ static bool test_writex(struct torture_context *tctx, { union smb_write io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum, i; uint8_t *buf; const int maxsize = 90000; @@ -242,10 +242,10 @@ static bool test_writex(struct torture_context *tctx, torture_comment(tctx, "dangerous not set - limiting range of test to 2^%d\n", max_bits); } - buf = talloc_zero_size(tctx, maxsize); + buf = talloc_zero_array(tctx, uint8_t, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_WRITE_WRITEX\n"); @@ -254,7 +254,7 @@ static bool test_writex(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -282,7 +282,7 @@ static bool test_writex(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf+4, seed, 9); @@ -301,7 +301,7 @@ static bool test_writex(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf, seed, 4000); @@ -334,7 +334,7 @@ static bool test_writex(struct torture_context *tctx, cli->session->pid++; if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum, 3, 1, 0, WRITE_LOCK))) { printf("Failed to lock file at %s\n", __location__); - ret = False; + ret = false; goto done; } cli->session->pid--; @@ -367,7 +367,7 @@ static bool test_writex(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf, seed, 4000); @@ -391,7 +391,7 @@ static bool test_writex(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, io.writex.in.offset, 4000) != 4000) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf, seed+1, 4000); @@ -416,7 +416,7 @@ static bool test_writeunlock(struct torture_context *tctx, { union smb_write io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; uint8_t *buf; const int maxsize = 90000; @@ -424,10 +424,10 @@ static bool test_writeunlock(struct torture_context *tctx, uint_t seed = time(NULL); union smb_fileinfo finfo; - buf = talloc_zero_size(tctx, maxsize); + buf = talloc_zero_array(tctx, uint8_t, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_WRITE_WRITEUNLOCK\n"); @@ -436,7 +436,7 @@ static bool test_writeunlock(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -460,7 +460,7 @@ static bool test_writeunlock(struct torture_context *tctx, CHECK_STATUS(status, NT_STATUS_RANGE_NOT_LOCKED); if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf+4, seed, 9); @@ -476,7 +476,7 @@ static bool test_writeunlock(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf+4, seed, 9); @@ -500,7 +500,7 @@ static bool test_writeunlock(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf, seed, 4000); @@ -538,7 +538,7 @@ static bool test_writeunlock(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, io.writeunlock.in.offset, 4000) != 4000) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf, seed, 4000); @@ -559,7 +559,7 @@ static bool test_writeclose(struct torture_context *tctx, { union smb_write io; NTSTATUS status; - BOOL ret = True; + bool ret = true; int fnum; uint8_t *buf; const int maxsize = 90000; @@ -567,10 +567,10 @@ static bool test_writeclose(struct torture_context *tctx, uint_t seed = time(NULL); union smb_fileinfo finfo; - buf = talloc_zero_size(tctx, maxsize); + buf = talloc_zero_array(tctx, uint8_t, maxsize); if (!torture_setup_dir(cli, BASEDIR)) { - return False; + return false; } printf("Testing RAW_WRITE_WRITECLOSE\n"); @@ -579,7 +579,7 @@ static bool test_writeclose(struct torture_context *tctx, fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum == -1) { printf("Failed to create %s - %s\n", fname, smbcli_errstr(cli->tree)); - ret = False; + ret = false; goto done; } @@ -614,7 +614,7 @@ static bool test_writeclose(struct torture_context *tctx, if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf+4, seed, 9); @@ -631,7 +631,7 @@ static bool test_writeclose(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, 0, 13) != 13) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf+4, seed, 9); @@ -656,7 +656,7 @@ static bool test_writeclose(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, 0, 4000) != 4000) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf, seed, 4000); @@ -695,7 +695,7 @@ static bool test_writeclose(struct torture_context *tctx, memset(buf, 0, maxsize); if (smbcli_read(cli->tree, fnum, buf, io.writeclose.in.offset, 4000) != 4000) { printf("read failed at %s\n", __location__); - ret = False; + ret = false; goto done; } CHECK_BUFFER(buf, seed, 4000); diff --git a/source4/torture/rpc/alter_context.c b/source4/torture/rpc/alter_context.c index 6dd0b40d7b..7843713074 100644 --- a/source4/torture/rpc/alter_context.c +++ b/source4/torture/rpc/alter_context.c @@ -28,86 +28,59 @@ bool torture_rpc_alter_context(struct torture_context *torture) { - NTSTATUS status; - struct dcerpc_pipe *p, *p2; - TALLOC_CTX *mem_ctx; - BOOL ret = True; + NTSTATUS status; + struct dcerpc_pipe *p, *p2, *p3; struct policy_handle *handle; struct ndr_interface_table tmptbl; struct ndr_syntax_id syntax; struct ndr_syntax_id transfer_syntax; - - mem_ctx = talloc_init("torture_rpc_alter_context"); + bool ret = true; torture_comment(torture, "opening LSA connection\n"); status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } + torture_assert_ntstatus_ok(torture, status, "connecting"); - if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) { - ret = False; + if (!test_lsa_OpenPolicy2(p, torture, &handle)) { + ret = false; } torture_comment(torture, "Opening secondary DSSETUP context\n"); status = dcerpc_secondary_context(p, &p2, &ndr_table_dssetup); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - torture_comment(torture, "dcerpc_alter_context failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed"); tmptbl = ndr_table_dssetup; tmptbl.syntax_id.if_version += 100; torture_comment(torture, "Opening bad secondary connection\n"); - status = dcerpc_secondary_context(p, &p2, &tmptbl); - if (NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - torture_comment(torture, "dcerpc_alter_context with wrong version should fail\n"); - return False; - } + status = dcerpc_secondary_context(p, &p3, &tmptbl); + torture_assert_ntstatus_equal(torture, status, NT_STATUS_RPC_UNSUPPORTED_NAME_SYNTAX, + "dcerpc_alter_context with wrong version should fail"); torture_comment(torture, "testing DSSETUP pipe operations\n"); - ret &= test_DsRoleGetPrimaryDomainInformation(p2, mem_ctx); + ret &= test_DsRoleGetPrimaryDomainInformation(torture, p2); if (handle) { - if (!test_lsa_Close(p, mem_ctx, handle)) { - ret = False; - } + ret &= test_lsa_Close(p, torture, handle); } syntax = p->syntax; transfer_syntax = p->transfer_syntax; torture_comment(torture, "Testing change of primary context\n"); - status = dcerpc_alter_context(p, mem_ctx, &p2->syntax, &p2->transfer_syntax); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - torture_comment(torture, "dcerpc_alter_context failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_alter_context(p, torture, &p2->syntax, &p2->transfer_syntax); + torture_assert_ntstatus_ok(torture, status, "dcerpc_alter_context failed"); torture_comment(torture, "testing DSSETUP pipe operations - should fault\n"); - if (test_DsRoleGetPrimaryDomainInformation(p, mem_ctx)) { - ret = False; - } + ret &= test_DsRoleGetPrimaryDomainInformation_ext(torture, p, NT_STATUS_NET_WRITE_FAULT); - if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) { - ret = False; - } + ret &= test_lsa_OpenPolicy2(p, torture, &handle); if (handle) { - if (!test_lsa_Close(p, mem_ctx, handle)) { - ret = False; - } + ret &= test_lsa_Close(p, torture, handle); } torture_comment(torture, "testing DSSETUP pipe operations\n"); - ret &= test_DsRoleGetPrimaryDomainInformation(p2, mem_ctx); - - talloc_free(mem_ctx); + ret &= test_DsRoleGetPrimaryDomainInformation(torture, p2); return ret; } diff --git a/source4/torture/rpc/async_bind.c b/source4/torture/rpc/async_bind.c index 155f3f8244..70743bd433 100644 --- a/source4/torture/rpc/async_bind.c +++ b/source4/torture/rpc/async_bind.c @@ -35,7 +35,7 @@ */ -BOOL torture_async_bind(struct torture_context *torture) +bool torture_async_bind(struct torture_context *torture) { NTSTATUS status; TALLOC_CTX *mem_ctx; @@ -49,30 +49,30 @@ BOOL torture_async_bind(struct torture_context *torture) struct dcerpc_pipe **pipe; const struct ndr_interface_table **table; - if (!torture_setting_bool(torture, "async", False)) { + if (!torture_setting_bool(torture, "async", false)) { printf("async bind test disabled - enable async tests to use\n"); - return True; + return true; } binding_string = torture_setting_string(torture, "binding", NULL); /* talloc context */ mem_ctx = talloc_init("torture_async_bind"); - if (mem_ctx == NULL) return False; + if (mem_ctx == NULL) return false; bind_req = talloc_array(torture, struct composite_context*, torture_numasync); - if (bind_req == NULL) return False; + if (bind_req == NULL) return false; pipe = talloc_array(torture, struct dcerpc_pipe*, torture_numasync); - if (pipe == NULL) return False; + if (pipe == NULL) return false; table = talloc_array(torture, const struct ndr_interface_table*, torture_numasync); - if (table == NULL) return False; + if (table == NULL) return false; /* credentials */ creds = cmdline_credentials; /* event context */ evt_ctx = cli_credentials_get_event_context(creds); - if (evt_ctx == NULL) return False; + if (evt_ctx == NULL) return false; /* send bind requests */ for (i = 0; i < torture_numasync; i++) { @@ -86,10 +86,10 @@ BOOL torture_async_bind(struct torture_context *torture) status = dcerpc_pipe_connect_recv(bind_req[i], mem_ctx, &pipe[i]); if (!NT_STATUS_IS_OK(status)) { printf("async rpc connection failed: %s\n", nt_errstr(status)); - return False; + return false; } } talloc_free(mem_ctx); - return True; + return true; } diff --git a/source4/torture/rpc/atsvc.c b/source4/torture/rpc/atsvc.c index f5295cc6cc..b0d1d1519d 100644 --- a/source4/torture/rpc/atsvc.c +++ b/source4/torture/rpc/atsvc.c @@ -76,7 +76,7 @@ static bool test_JobEnum(struct torture_context *tctx, struct dcerpc_pipe *p) for (i = 0; i < r.out.ctr->entries_read; i++) { if (!test_JobGetInfo(p, tctx, r.out.ctr->first_entry[i].job_id)) { - ret = False; + ret = false; } } @@ -118,15 +118,12 @@ static bool test_JobAdd(struct torture_context *tctx, struct dcerpc_pipe *p) return true; } -struct torture_suite *torture_rpc_atsvc(void) +struct torture_suite *torture_rpc_atsvc(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create( - talloc_autofree_context(), - "ATSVC"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "ATSVC"); struct torture_rpc_tcase *tcase; - tcase = torture_suite_add_rpc_iface_tcase(suite, "atsvc", - &ndr_table_atsvc); + tcase = torture_suite_add_rpc_iface_tcase(suite, "atsvc", &ndr_table_atsvc); torture_rpc_tcase_add_test(tcase, "JobEnum", test_JobEnum); torture_rpc_tcase_add_test(tcase, "JobAdd", test_JobAdd); diff --git a/source4/torture/rpc/autoidl.c b/source4/torture/rpc/autoidl.c index 76d838517c..9343734413 100644 --- a/source4/torture/rpc/autoidl.c +++ b/source4/torture/rpc/autoidl.c @@ -31,7 +31,7 @@ /* get a DRSUAPI policy handle */ -static BOOL get_policy_handle(struct dcerpc_pipe *p, +static bool get_policy_handle(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -44,16 +44,16 @@ static BOOL get_policy_handle(struct dcerpc_pipe *p, status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("drsuapi_DsBind failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } #else /* get a SAMR handle */ -static BOOL get_policy_handle(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool get_policy_handle(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -66,10 +66,10 @@ static BOOL get_policy_handle(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Connect(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("samr_Connect failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } #endif @@ -95,8 +95,7 @@ static void reopen(TALLOC_CTX *mem_ctx, talloc_free(*p); - status = torture_rpc_connection(mem_ctx, - p, iface); + status = torture_rpc_connection(mem_ctx, p, iface); if (!NT_STATUS_IS_OK(status)) { printf("Failed to reopen '%s' - %s\n", iface->name, nt_errstr(status)); exit(1); @@ -131,7 +130,7 @@ static void try_expand(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *if memcpy(stub_in.data, base_in->data, insert_ofs); memcpy(stub_in.data+insert_ofs+n, base_in->data+insert_ofs, base_in->length-insert_ofs); - status = dcerpc_request(p, NULL, opnum, False, mem_ctx, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out); if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { print_depth(depth); @@ -172,7 +171,7 @@ static void test_ptr_scan(TALLOC_CTX *mem_ctx, const struct ndr_interface_table /* work out which elements are pointers */ for (ofs=min_ofs;ofs<=max_ofs-4;ofs+=4) { SIVAL(stub_in.data, ofs, 1); - status = dcerpc_request(p, NULL, opnum, False, mem_ctx, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { print_depth(depth); @@ -214,7 +213,7 @@ static void test_scan_call(TALLOC_CTX *mem_ctx, const struct ndr_interface_table data_blob_clear(&stub_in); - status = dcerpc_request(p, NULL, opnum, False, mem_ctx, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out); if (NT_STATUS_IS_OK(status)) { printf("opnum %d min_input %d - output %d\n", @@ -227,7 +226,7 @@ static void test_scan_call(TALLOC_CTX *mem_ctx, const struct ndr_interface_table fill_blob_handle(&stub_in, mem_ctx, &handle); - status = dcerpc_request(p, NULL, opnum, False, mem_ctx, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, opnum, false, mem_ctx, &stub_in, &stub_out); if (NT_STATUS_IS_OK(status)) { printf("opnum %d min_input %d - output %d (with handle)\n", @@ -259,7 +258,7 @@ static void test_auto_scan(TALLOC_CTX *mem_ctx, const struct ndr_interface_table test_scan_call(mem_ctx, iface, 2); } -BOOL torture_rpc_autoidl(struct torture_context *torture) +bool torture_rpc_autoidl(struct torture_context *torture) { TALLOC_CTX *mem_ctx; const struct ndr_interface_table *iface; @@ -267,7 +266,7 @@ BOOL torture_rpc_autoidl(struct torture_context *torture) iface = ndr_table_by_name("drsuapi"); if (!iface) { printf("Unknown interface!\n"); - return False; + return false; } mem_ctx = talloc_init("torture_rpc_autoidl"); @@ -277,5 +276,5 @@ BOOL torture_rpc_autoidl(struct torture_context *torture) test_auto_scan(mem_ctx, iface); talloc_free(mem_ctx); - return True; + return true; } diff --git a/source4/torture/rpc/bench.c b/source4/torture/rpc/bench.c index 48fd0609f0..2619ac2d25 100644 --- a/source4/torture/rpc/bench.c +++ b/source4/torture/rpc/bench.c @@ -23,18 +23,19 @@ #include "torture/torture.h" #include "librpc/gen_ndr/ndr_srvsvc_c.h" #include "torture/rpc/rpc.h" +#include "param/param.h" /**************************/ /* srvsvc_NetShare */ /**************************/ -static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { NTSTATUS status; struct srvsvc_NetShareEnumAll r; struct srvsvc_NetShareCtr0 c0; uint32_t levels[] = {0, 1, 2, 501, 502}; int i; - BOOL ret = True; + bool ret = true; uint32_t resume_handle; ZERO_STRUCT(c0); @@ -52,7 +53,7 @@ static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) status = dcerpc_srvsvc_NetShareEnumAll(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("NetShareEnumAll level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; continue; } if (!W_ERROR_IS_OK(r.out.result)) { @@ -67,11 +68,11 @@ static BOOL test_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) /* benchmark srvsvc netshareenumall queries */ -static BOOL bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { struct timeval tv = timeval_current(); - BOOL ret = True; - int timelimit = lp_parm_int(-1, "torture", "timelimit", 10); + bool ret = true; + int timelimit = lp_parm_int(global_loadparm, NULL, "torture", "timelimit", 10); int count=0; printf("Running for %d seconds\n", timelimit); @@ -81,7 +82,7 @@ static BOOL bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) talloc_free(tmp_ctx); count++; if (count % 50 == 0) { - if (lp_parm_bool(-1, "torture", "progress", true)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "progress", true)) { printf("%.1f queries per second \r", count / timeval_elapsed(&tv)); } @@ -94,12 +95,12 @@ static BOOL bench_NetShareEnumAll(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) } -BOOL torture_bench_rpc(struct torture_context *torture) +bool torture_bench_rpc(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; mem_ctx = talloc_init("torture_rpc_srvsvc"); @@ -108,11 +109,11 @@ BOOL torture_bench_rpc(struct torture_context *torture) &ndr_table_srvsvc); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); - return False; + return false; } if (!bench_NetShareEnumAll(p, mem_ctx)) { - ret = False; + ret = false; } talloc_free(mem_ctx); diff --git a/source4/torture/rpc/bind.c b/source4/torture/rpc/bind.c index c7848f4a89..1800901873 100644 --- a/source4/torture/rpc/bind.c +++ b/source4/torture/rpc/bind.c @@ -41,27 +41,27 @@ */ -BOOL torture_multi_bind(struct torture_context *torture) +bool torture_multi_bind(struct torture_context *torture) { struct dcerpc_pipe *p; struct dcerpc_binding *binding; TALLOC_CTX *mem_ctx; NTSTATUS status; - BOOL ret; + bool ret; mem_ctx = talloc_init("torture_multi_bind"); status = torture_rpc_binding(torture, &binding); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); - return False; + return false; } status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); - return False; + return false; } status = dcerpc_pipe_auth(mem_ctx, &p, binding, &ndr_table_lsarpc, cmdline_credentials); @@ -69,10 +69,10 @@ BOOL torture_multi_bind(struct torture_context *torture) if (NT_STATUS_IS_OK(status)) { printf("(incorrectly) allowed re-bind to uuid %s - %s\n", GUID_string(mem_ctx, &ndr_table_lsarpc.syntax_id.uuid), nt_errstr(status)); - ret = False; + ret = false; } else { printf("\n"); - ret = True; + ret = true; } talloc_free(mem_ctx); diff --git a/source4/torture/rpc/countcalls.c b/source4/torture/rpc/countcalls.c index e2e222d2ec..f9a31feaaf 100644 --- a/source4/torture/rpc/countcalls.c +++ b/source4/torture/rpc/countcalls.c @@ -25,12 +25,13 @@ #include "librpc/ndr/libndr.h" #include "librpc/ndr/ndr_table.h" #include "torture/rpc/rpc.h" +#include "param/param.h" -BOOL count_calls(TALLOC_CTX *mem_ctx, +bool count_calls(TALLOC_CTX *mem_ctx, const struct ndr_interface_table *iface, - BOOL all) + bool all) { struct dcerpc_pipe *p; DATA_BLOB stub_in, stub_out; @@ -42,14 +43,14 @@ BOOL count_calls(TALLOC_CTX *mem_ctx, || NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) { if (all) { /* Not fatal if looking for all pipes */ - return True; + return true; } else { printf("Failed to open '%s' to count calls - %s\n", iface->name, nt_errstr(status)); - return False; + return false; } } else if (!NT_STATUS_IS_OK(status)) { printf("Failed to open '%s' to count calls - %s\n", iface->name, nt_errstr(status)); - return False; + return false; } stub_in = data_blob_talloc(p, mem_ctx, 0); @@ -57,7 +58,7 @@ BOOL count_calls(TALLOC_CTX *mem_ctx, printf("\nScanning pipe '%s'\n", iface->name); for (i=0;i<500;i++) { - status = dcerpc_request(p, NULL, i, False, p, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, i, false, p, &stub_in, &stub_out); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT) && p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) { i--; @@ -89,41 +90,41 @@ BOOL count_calls(TALLOC_CTX *mem_ctx, if (i==500) { talloc_free(p); printf("no limit on calls: %s!?\n", nt_errstr(status)); - return False; + return false; } printf("Found %d calls\n", i); talloc_free(p); - return True; + return true; } -BOOL torture_rpc_countcalls(struct torture_context *torture) +bool torture_rpc_countcalls(struct torture_context *torture) { const struct ndr_interface_table *iface; const char *iface_name; - BOOL ret = True; + bool ret = true; const struct ndr_interface_list *l; TALLOC_CTX *mem_ctx = talloc_named(torture, 0, "torture_rpc_countcalls context"); if (!mem_ctx) { - return False; + return false; } - iface_name = lp_parm_string(-1, "countcalls", "interface"); + iface_name = lp_parm_string(global_loadparm, NULL, "countcalls", "interface"); if (iface_name != NULL) { iface = ndr_table_by_name(iface_name); if (!iface) { printf("Unknown interface '%s'\n", iface_name); - return False; + return false; } - return count_calls(mem_ctx, iface, False); + return count_calls(mem_ctx, iface, false); } for (l=ndr_table_list();l;l=l->next) { TALLOC_CTX *loop_ctx; loop_ctx = talloc_named(mem_ctx, 0, "torture_rpc_councalls loop context"); - ret &= count_calls(loop_ctx, l->table, True); + ret &= count_calls(loop_ctx, l->table, true); talloc_free(loop_ctx); } return ret; diff --git a/source4/torture/rpc/dfs.c b/source4/torture/rpc/dfs.c index 7dc600ae93..afa647e71c 100644 --- a/source4/torture/rpc/dfs.c +++ b/source4/torture/rpc/dfs.c @@ -38,12 +38,12 @@ if (x == DFS_MANAGER_VERSION_W2K3) {\ if (!W_ERROR_EQUAL(y,WERR_NOT_SUPPORTED)) {\ printf("expected WERR_NOT_SUPPORTED\n");\ - return False;\ + return false;\ }\ - return True;\ + return true;\ }\ -static BOOL test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char *sharename, const char *dir) +static bool test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char *sharename, const char *dir) { NTSTATUS status; struct srvsvc_NetShareInfo2 i; @@ -53,7 +53,7 @@ static BOOL test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char * printf("Creating share %s\n", sharename); if (!(libnetctx = libnet_context_init(NULL))) { - return False; + return false; } libnetctx->cred = cmdline_credentials; @@ -75,13 +75,13 @@ static BOOL test_NetShareAdd(TALLOC_CTX *mem_ctx, const char *host, const char * if (!NT_STATUS_IS_OK(status)) { d_printf("Failed to add new share: %s (%s)\n", nt_errstr(status), r.out.error_string); - return False; + return false; } - return True; + return true; } -static BOOL test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char *sharename) +static bool test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char *sharename) { NTSTATUS status; struct libnet_context* libnetctx; @@ -90,7 +90,7 @@ static BOOL test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char * printf("Deleting share %s\n", sharename); if (!(libnetctx = libnet_context_init(NULL))) { - return False; + return false; } libnetctx->cred = cmdline_credentials; @@ -102,13 +102,13 @@ static BOOL test_NetShareDel(TALLOC_CTX *mem_ctx, const char *host, const char * if (!NT_STATUS_IS_OK(status)) { d_printf("Failed to delete share: %s (%s)\n", nt_errstr(status), r.out.error_string); - return False; + return false; } - return True; + return true; } -static BOOL test_CreateDir(TALLOC_CTX *mem_ctx, +static bool test_CreateDir(TALLOC_CTX *mem_ctx, struct smbcli_state **cli, const char *host, const char *share, @@ -117,29 +117,29 @@ static BOOL test_CreateDir(TALLOC_CTX *mem_ctx, printf("Creating directory %s\n", dir); if (!torture_open_connection_share(mem_ctx, cli, host, share, NULL)) { - return False; + return false; } if (!torture_setup_dir(*cli, dir)) { - return False; + return false; } - return True; + return true; } -static BOOL test_DeleteDir(struct smbcli_state *cli, const char *dir) +static bool test_DeleteDir(struct smbcli_state *cli, const char *dir) { printf("Deleting directory %s\n", dir); if (smbcli_deltree(cli->tree, dir) == -1) { printf("Unable to delete dir %s - %s\n", dir, smbcli_errstr(cli->tree)); - return False; + return false; } - return True; + return true; } -static BOOL test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, enum dfs_ManagerVersion *version) +static bool test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, enum dfs_ManagerVersion *version) { NTSTATUS status; struct dfs_GetManagerVersion r; @@ -149,13 +149,13 @@ static BOOL test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, e status = dcerpc_dfs_GetManagerVersion(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("GetManagerVersion failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host) +static bool test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host) { NTSTATUS status; enum dfs_ManagerVersion version; @@ -164,7 +164,7 @@ static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c printf("Testing ManagerInitialize\n"); if (!test_GetManagerVersion(p, mem_ctx, &version)) { - return False; + return false; } r.in.servername = host; @@ -173,17 +173,17 @@ static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c status = dcerpc_dfs_ManagerInitialize(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("ManagerInitialize failed - %s\n", nt_errstr(status)); - return False; + return false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("dfs_ManagerInitialize failed - %s\n", win_errstr(r.out.result)); IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result); - return False; + return false; } - return True; + return true; } -static BOOL test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, +static bool test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, const char *root) { NTSTATUS status; @@ -199,32 +199,32 @@ static BOOL test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16 status = dcerpc_dfs_GetInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("GetInfo failed - %s\n", nt_errstr(status)); - return False; + return false; } else if (!W_ERROR_IS_OK(r.out.result) && !W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) { printf("dfs_GetInfo failed - %s\n", win_errstr(r.out.result)); - return False; + return false; } - return True; + return true; } -static BOOL test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root) +static bool test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root) { - BOOL ret = True; + bool ret = true; /* 103, 104, 105, 106 is only available on Set */ uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 100, 101, 102, 103, 104, 105, 106}; int i; for (i=0;i<ARRAY_SIZE(levels);i++) { if (!test_GetInfoLevel(p, mem_ctx, levels[i], root)) { - ret = False; + ret = false; } } return ret; } -static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, const char *dfs_name) +static bool test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, const char *dfs_name) { NTSTATUS status; struct dfs_EnumEx rex; @@ -232,7 +232,7 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_ struct dfs_EnumStruct e; struct dfs_Info1 s; struct dfs_EnumArray1 e1; - BOOL ret = True; + bool ret = true; rex.in.level = level; rex.in.bufsize = (uint32_t)-1; @@ -251,7 +251,7 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_ status = dcerpc_dfs_EnumEx(p, mem_ctx, &rex); if (!NT_STATUS_IS_OK(status)) { printf("EnumEx failed - %s\n", nt_errstr(status)); - return False; + return false; } if (level == 1 && rex.out.total) { @@ -259,7 +259,7 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_ for (i=0;i<*rex.out.total;i++) { const char *root = talloc_strdup(mem_ctx, rex.out.info->e.info1->s[i].path); if (!test_GetInfo(p, mem_ctx, root)) { - ret = False; + ret = false; } } } @@ -271,11 +271,11 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_ const char *root = talloc_strdup(mem_ctx, rex.out.info->e.info300->s[i].dom_root); for (k=0;k<ARRAY_SIZE(levels);k++) { if (!test_EnumLevelEx(p, mem_ctx, levels[k], root)) { - ret = False; + ret = false; } } if (!test_GetInfo(p, mem_ctx, root)) { - ret = False; + ret = false; } } } @@ -284,7 +284,7 @@ static BOOL test_EnumLevelEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_ } -static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level) +static bool test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level) { NTSTATUS status; struct dfs_Enum r; @@ -292,7 +292,7 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t struct dfs_EnumStruct e; struct dfs_Info1 s; struct dfs_EnumArray1 e1; - BOOL ret = True; + bool ret = true; r.in.level = level; r.in.bufsize = (uint32_t)-1; @@ -310,11 +310,11 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t status = dcerpc_dfs_Enum(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Enum failed - %s\n", nt_errstr(status)); - return False; + return false; } else if (!W_ERROR_IS_OK(r.out.result) && !W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) { printf("dfs_Enum failed - %s\n", win_errstr(r.out.result)); - return False; + return false; } if (level == 1 && r.out.total) { @@ -322,7 +322,7 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t for (i=0;i<*r.out.total;i++) { const char *root = r.out.info->e.info1->s[i].path; if (!test_GetInfo(p, mem_ctx, root)) { - ret = False; + ret = false; } } @@ -332,37 +332,37 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t } -static BOOL test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { - BOOL ret = True; + bool ret = true; uint16_t levels[] = {1, 2, 3, 4, 200, 300}; int i; for (i=0;i<ARRAY_SIZE(levels);i++) { if (!test_EnumLevel(p, mem_ctx, levels[i])) { - ret = False; + ret = false; } } return ret; } -static BOOL test_EnumEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host) +static bool test_EnumEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host) { - BOOL ret = True; + bool ret = true; uint16_t levels[] = {1, 2, 3, 4, 200, 300}; int i; for (i=0;i<ARRAY_SIZE(levels);i++) { if (!test_EnumLevelEx(p, mem_ctx, levels[i], host)) { - ret = False; + ret = false; } } return ret; } -static BOOL test_RemoveStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename) +static bool test_RemoveStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename) { struct dfs_RemoveStdRoot r; NTSTATUS status; @@ -376,16 +376,16 @@ static BOOL test_RemoveStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const status = dcerpc_dfs_RemoveStdRoot(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("RemoveStdRoot failed - %s\n", nt_errstr(status)); - return False; + return false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("dfs_RemoveStdRoot failed - %s\n", win_errstr(r.out.result)); - return False; + return false; } - return True; + return true; } -static BOOL test_AddStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename) +static bool test_AddStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename) { NTSTATUS status; struct dfs_AddStdRoot r; @@ -400,16 +400,16 @@ static BOOL test_AddStdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const ch status = dcerpc_dfs_AddStdRoot(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("AddStdRoot failed - %s\n", nt_errstr(status)); - return False; + return false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("dfs_AddStdRoot failed - %s\n", win_errstr(r.out.result)); - return False; + return false; } - return True; + return true; } -static BOOL test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename) +static bool test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host, const char *sharename) { NTSTATUS status; struct dfs_AddStdRootForced r; @@ -418,7 +418,7 @@ static BOOL test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, co printf("Testing AddStdRootForced\n"); if (!test_GetManagerVersion(p, mem_ctx, &version)) { - return False; + return false; } r.in.servername = host; @@ -429,11 +429,11 @@ static BOOL test_AddStdRootForced(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, co status = dcerpc_dfs_AddStdRootForced(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("AddStdRootForced failed - %s\n", nt_errstr(status)); - return False; + return false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("dfs_AddStdRootForced failed - %s\n", win_errstr(r.out.result)); IS_DFS_VERSION_UNSUPPORTED_CALL_W2K3(version, r.out.result); - return False; + return false; } return test_RemoveStdRoot(p, mem_ctx, host, sharename); @@ -456,13 +456,13 @@ static void test_cleanup_stdroot(struct dcerpc_pipe *p, torture_close_connection(cli); } -static BOOL test_StdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host) +static bool test_StdRoot(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host) { const char *sharename = SMBTORTURE_DFS_SHARENAME; const char *dir = SMBTORTURE_DFS_DIRNAME; const char *path = SMBTORTURE_DFS_PATHNAME; struct smbcli_state *cli; - BOOL ret; + bool ret; printf("Testing StdRoot\n"); @@ -485,9 +485,9 @@ bool torture_rpc_dfs(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - BOOL ret = True; + bool ret = true; enum dfs_ManagerVersion version; - const char *host = lp_parm_string(-1, "torture", "host"); + const char *host = torture_setting_string(torture, "host", NULL); status = torture_rpc_connection(torture, &p, &ndr_table_netdfs); torture_assert_ntstatus_ok(torture, status, "Unable to connect"); diff --git a/source4/torture/rpc/drsuapi.c b/source4/torture/rpc/drsuapi.c index 606240993f..3407e49565 100644 --- a/source4/torture/rpc/drsuapi.c +++ b/source4/torture/rpc/drsuapi.c @@ -25,15 +25,15 @@ #include "torture/torture.h" #include "librpc/gen_ndr/ndr_drsuapi_c.h" #include "torture/rpc/rpc.h" +#include "param/param.h" #define TEST_MACHINE_NAME "torturetest" -BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_DsBind(struct dcerpc_pipe *p, struct torture_context *tctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsBind r; - BOOL ret = True; GUID_from_string(DRSUAPI_DS_BIND_GUID, &priv->bind_guid); @@ -41,31 +41,28 @@ BOOL test_DsBind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.bind_info = NULL; r.out.bind_handle = &priv->bind_handle; - printf("testing DsBind\n"); + torture_comment(tctx, "testing DsBind\n"); - status = dcerpc_drsuapi_DsBind(p, mem_ctx, &r); + status = dcerpc_drsuapi_DsBind(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { const char *errstr = nt_errstr(status); if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); + errstr = dcerpc_errstr(tctx, p->last_fault_code); } - printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr); - ret = False; + torture_fail(tctx, "dcerpc_drsuapi_DsBind failed"); } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsBind failed - %s\n", win_errstr(r.out.result)); - ret = False; + torture_fail(tctx, "DsBind failed"); } - return ret; + return true; } -static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, struct torture_context *torture, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsGetDomainControllerInfo r; - BOOL ret = True; - BOOL found = False; + bool found = false; int i, j, k; struct { @@ -101,45 +98,32 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me r.in.req.req1.domain_name = names[j].name; r.in.req.req1.level = level; - printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", + torture_comment(torture, + "testing DsGetDomainControllerInfo level %d on domainname '%s'\n", r.in.req.req1.level, r.in.req.req1.domain_name); - status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, errstr); - ret = False; - } else if (!W_ERROR_EQUAL(r.out.result, names[j].expected)) { - printf("DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s, expected %s\n", - r.in.req.req1.level, win_errstr(r.out.result), - win_errstr(names[j].expected)); - ret = False; - } + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); + torture_assert_ntstatus_ok(torture, status, + "dcerpc_drsuapi_DsGetDomainControllerInfo with dns domain failed"); + torture_assert_werr_equal(torture, + r.out.result, names[j].expected, + "DsGetDomainControllerInfo level with dns domain failed"); if (!W_ERROR_IS_OK(r.out.result)) { /* If this was an error, we can't read the result structure */ continue; } - if (r.in.req.req1.level != r.out.level_out) { - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level in (%d) != out (%d)\n", - r.in.req.req1.level, r.out.level_out); - ret = False; - /* We can't safely read the result structure */ - continue; - } + torture_assert_int_equal(torture, + r.in.req.req1.level, r.out.level_out, + "dcerpc_drsuapi_DsGetDomainControllerInfo level"); + switch (level) { case 1: for (k=0; k < r.out.ctr.ctr1.count; k++) { if (strcasecmp_m(r.out.ctr.ctr1.array[k].netbios_name, torture_join_netbios_name(priv->join)) == 0) { - found = True; + found = true; break; } } @@ -148,27 +132,18 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me for (k=0; k < r.out.ctr.ctr2.count; k++) { if (strcasecmp_m(r.out.ctr.ctr2.array[k].netbios_name, torture_join_netbios_name(priv->join)) == 0) { - found = True; + found = true; priv->dcinfo = r.out.ctr.ctr2.array[k]; break; } } break; } - if (!found) { - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) we just created during the join\n", - r.in.req.req1.level, - torture_join_netbios_name(priv->join)); - ret = False; - } + torture_assert(torture, found, + "dcerpc_drsuapi_DsGetDomainControllerInfo: Failed to find the domain controller we just created during the join"); } } - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsGetDomainControllerInfo level -1 test against Samba4\n"); - return ret; - } - r.in.bind_handle = &priv->bind_handle; r.in.level = 1; @@ -178,53 +153,39 @@ static BOOL test_DsGetDomainControllerInfo(struct dcerpc_pipe *p, TALLOC_CTX *me printf("testing DsGetDomainControllerInfo level %d on domainname '%s'\n", r.in.req.req1.level, r.in.req.req1.domain_name); - status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsGetDomainControllerInfo level %d\n" - " with dns domain failed - %s\n", - r.in.req.req1.level, win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_drsuapi_DsGetDomainControllerInfo(p, torture, &r); + + torture_assert_ntstatus_ok(torture, status, + "dcerpc_drsuapi_DsGetDomainControllerInfo with dns domain failed"); + torture_assert_werr_ok(torture, r.out.result, + "DsGetDomainControllerInfo with dns domain failed"); { - const char *dc_account = talloc_asprintf(mem_ctx, "%s\\%s$", + const char *dc_account = talloc_asprintf(torture, "%s\\%s$", torture_join_dom_netbios_name(priv->join), priv->dcinfo.netbios_name); for (k=0; k < r.out.ctr.ctr01.count; k++) { if (strcasecmp_m(r.out.ctr.ctr01.array[k].client_account, dc_account)) { - found = True; + found = true; break; } } - if (!found) { - printf("dcerpc_drsuapi_DsGetDomainControllerInfo level %d: Failed to find the domain controller (%s) in last logon records\n", - r.in.req.req1.level, - dc_account); - ret = False; - } + torture_assert(torture, found, + "dcerpc_drsuapi_DsGetDomainControllerInfo level: Failed to find the domain controller in last logon records"); } - return ret; + return true; } -static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsWriteAccountSpn r; struct drsuapi_DsNameString names[2]; - BOOL ret = True; + bool ret = true; r.in.bind_handle = &priv->bind_handle; r.in.level = 1; @@ -246,10 +207,10 @@ static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } r.in.req.req1.operation = DRSUAPI_DS_SPN_OPERATION_DELETE; @@ -262,21 +223,21 @@ static BOOL test_DsWriteAccountSpn(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsWriteAccountSpn failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsWriteAccountSpn failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } return ret; } -static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsReplicaGetInfo r; - BOOL ret = True; + bool ret = true; int i; struct { int32_t level; @@ -346,9 +307,9 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping DsReplicaGetInfo test against Samba4\n"); - return True; + return true; } r.in.bind_handle = &priv->bind_handle; @@ -387,25 +348,25 @@ static BOOL test_DsReplicaGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } if (p->last_fault_code != DCERPC_FAULT_INVALID_TAG) { printf("dcerpc_drsuapi_DsReplicaGetInfo failed - %s\n", errstr); - ret = False; + ret = false; } else { printf("DsReplicaGetInfo level %d and/or infotype %d not supported by server\n", array[i].level, array[i].infotype); } } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsReplicaGetInfo failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } } return ret; } -static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; - BOOL ret = True; + bool ret = true; int i; struct drsuapi_DsReplicaSync r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -419,14 +380,14 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (!lp_parm_bool(-1, "torture", "dangerous", False)) { + if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) { printf("DsReplicaSync disabled - enable dangerous tests to use\n"); - return True; + return true; } - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping DsReplicaSync test against Samba4\n"); - return True; + return true; } ZERO_STRUCT(null_guid); @@ -459,21 +420,21 @@ static BOOL test_DsReplicaSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsReplicaSync failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsReplicaSync failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } } return ret; } -static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; - BOOL ret = True; + bool ret = true; int i; struct drsuapi_DsReplicaUpdateRefs r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -487,9 +448,9 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping DsReplicaUpdateRefs test against Samba4\n"); - return True; + return true; } ZERO_STRUCT(null_guid); @@ -523,21 +484,21 @@ static BOOL test_DsReplicaUpdateRefs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsReplicaUpdateRefs failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsReplicaUpdateRefs failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } } return ret; } -static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; - BOOL ret = True; + bool ret = true; int i; struct drsuapi_DsGetNCChanges r; struct drsuapi_DsReplicaObjectIdentifier nc; @@ -554,9 +515,9 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } }; - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping DsGetNCChanges test against Samba4\n"); - return True; + return true; } ZERO_STRUCT(null_guid); @@ -583,7 +544,7 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req5.highwatermark.highest_usn = 0; r.in.req.req5.uptodateness_vector = NULL; r.in.req.req5.replica_flags = 0; - if (lp_parm_bool(-1, "drsuapi","compression", False)) { + if (lp_parm_bool(global_loadparm, NULL, "drsuapi","compression", false)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } r.in.req.req5.max_object_count = 0; @@ -605,10 +566,10 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.req.req8.highwatermark.highest_usn = 0; r.in.req.req8.uptodateness_vector = NULL; r.in.req.req8.replica_flags = 0; - if (lp_parm_bool(-1,"drsuapi","compression",False)) { + if (lp_parm_bool(global_loadparm, NULL, "drsuapi", "compression", false)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(-1,"drsuapi","neighbour_writeable",True)) { + if (lp_parm_bool(global_loadparm, NULL, "drsuapi", "neighbour_writeable", true)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP @@ -635,22 +596,22 @@ static BOOL test_DsGetNCChanges(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } } return ret; } -BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_QuerySitesByCost r; - BOOL ret = True; + bool ret = true; const char *my_site = "Default-First-Site-Name"; const char *remote_site1 = "smbtorture-nonexisting-site1"; @@ -672,10 +633,10 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("drsuapi_QuerySitesByCost - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("QuerySitesByCost failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } if (W_ERROR_IS_OK(r.out.result)) { @@ -684,14 +645,14 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, !W_ERROR_EQUAL(r.out.ctr.ctr1.info[1].error_code, WERR_DS_OBJ_NOT_FOUND)) { printf("expected error_code WERR_DS_OBJ_NOT_FOUND, got %s\n", win_errstr(r.out.ctr.ctr1.info[0].error_code)); - ret = False; + ret = false; } if ((r.out.ctr.ctr1.info[0].site_cost != (uint32_t) -1) || (r.out.ctr.ctr1.info[1].site_cost != (uint32_t) -1)) { printf("expected site_cost %d, got %d\n", (uint32_t) -1, r.out.ctr.ctr1.info[0].site_cost); - ret = False; + ret = false; } } @@ -700,12 +661,12 @@ BOOL test_QuerySitesByCost(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsUnbind r; - BOOL ret = True; + bool ret = true; r.in.bind_handle = &priv->bind_handle; r.out.bind_handle = &priv->bind_handle; @@ -719,34 +680,29 @@ BOOL test_DsUnbind(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsUnbind failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsBind failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } return ret; } -BOOL torture_rpc_drsuapi(struct torture_context *torture) +bool torture_rpc_drsuapi(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct DsPrivate priv; struct cli_credentials *machine_credentials; - mem_ctx = talloc_init("torture_rpc_drsuapi"); - ZERO_STRUCT(priv); priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, &machine_credentials); if (!priv.join) { - talloc_free(mem_ctx); - printf("Failed to join as BDC\n"); - return False; + torture_fail(torture, "Failed to join as BDC"); } status = torture_rpc_connection(torture, @@ -754,31 +710,28 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { torture_leave_domain(priv.join); - talloc_free(mem_ctx); - return False; + torture_fail(torture, "Unable to connect to DRSUAPI pipe"); } - ret &= test_DsBind(p, mem_ctx, &priv); + ret &= test_DsBind(p, torture, &priv); #if 0 - ret &= test_QuerySitesByCost(p, mem_ctx, &priv); + ret &= test_QuerySitesByCost(p, torture, &priv); #endif - ret &= test_DsGetDomainControllerInfo(p, mem_ctx, &priv); - - ret &= test_DsCrackNames(p, mem_ctx, &priv); + ret &= test_DsGetDomainControllerInfo(p, torture, &priv); - ret &= test_DsWriteAccountSpn(p, mem_ctx, &priv); + ret &= test_DsCrackNames(p, torture, &priv); - ret &= test_DsReplicaGetInfo(p, mem_ctx, &priv); + ret &= test_DsWriteAccountSpn(p, torture, &priv); - ret &= test_DsReplicaSync(p, mem_ctx, &priv); + ret &= test_DsReplicaGetInfo(p, torture, &priv); - ret &= test_DsReplicaUpdateRefs(p, mem_ctx, &priv); + ret &= test_DsReplicaSync(p, torture, &priv); - ret &= test_DsGetNCChanges(p, mem_ctx, &priv); + ret &= test_DsReplicaUpdateRefs(p, torture, &priv); - ret &= test_DsUnbind(p, mem_ctx, &priv); + ret &= test_DsGetNCChanges(p, torture, &priv); - talloc_free(mem_ctx); + ret &= test_DsUnbind(p, torture, &priv); torture_leave_domain(priv.join); @@ -786,27 +739,22 @@ BOOL torture_rpc_drsuapi(struct torture_context *torture) } -BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture) +bool torture_rpc_drsuapi_cracknames(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct DsPrivate priv; struct cli_credentials *machine_credentials; - mem_ctx = talloc_init("torture_rpc_drsuapi"); - - printf("Connected to DRAUAPI pipe\n"); + torture_comment(torture, "Connected to DRSUAPI pipe\n"); ZERO_STRUCT(priv); priv.join = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, &machine_credentials); if (!priv.join) { - talloc_free(mem_ctx); - printf("Failed to join as BDC\n"); - return False; + torture_fail(torture, "Failed to join as BDC\n"); } status = torture_rpc_connection(torture, @@ -814,21 +762,19 @@ BOOL torture_rpc_drsuapi_cracknames(struct torture_context *torture) &ndr_table_drsuapi); if (!NT_STATUS_IS_OK(status)) { torture_leave_domain(priv.join); - talloc_free(mem_ctx); - return False; + torture_fail(torture, "Unable to connect to DRSUAPI pipe"); } - ret &= test_DsBind(p, mem_ctx, &priv); + ret &= test_DsBind(p, torture, &priv); if (ret) { /* We don't care if this fails, we just need some info from it */ - test_DsGetDomainControllerInfo(p, mem_ctx, &priv); + test_DsGetDomainControllerInfo(p, torture, &priv); - ret &= test_DsCrackNames(p, mem_ctx, &priv); + ret &= test_DsCrackNames(p, torture, &priv); - ret &= test_DsUnbind(p, mem_ctx, &priv); + ret &= test_DsUnbind(p, torture, &priv); } - talloc_free(mem_ctx); torture_leave_domain(priv.join); diff --git a/source4/torture/rpc/drsuapi_cracknames.c b/source4/torture/rpc/drsuapi_cracknames.c index a29010f73b..ac3eebfa68 100644 --- a/source4/torture/rpc/drsuapi_cracknames.c +++ b/source4/torture/rpc/drsuapi_cracknames.c @@ -27,15 +27,16 @@ #include "torture/rpc/rpc.h" #include "ldb/include/ldb.h" #include "libcli/security/security.h" +#include "param/param.h" -static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv, const char *dn, const char *user_principal_name, const char *service_principal_name) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct drsuapi_DsCrackNames r; enum drsuapi_DsNameFormat formats[] = { DRSUAPI_DS_NAME_FORMAT_FQDN_1779, @@ -80,13 +81,13 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired); printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("testing DsCrackNames (matrix prep) with name '%s' from format: %d desired format:%d ", names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired); printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } if (!ret) { @@ -97,7 +98,7 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE) { printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", r.out.ctr.ctr1->array[0].status); - return False; + return false; } printf ("(expected) error\n"); break; @@ -105,7 +106,7 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_NO_MAPPING) { printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", r.out.ctr.ctr1->array[0].status); - return False; + return false; } printf ("(expected) error\n"); break; @@ -114,14 +115,14 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_RESOLVE_ERROR) { printf(__location__ ": Unexpected error (%d): This name lookup should fail\n", r.out.ctr.ctr1->array[0].status); - return False; + return false; } printf ("(expected) error\n"); break; default: if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { printf("Error: %d\n", r.out.ctr.ctr1->array[0].status); - return False; + return false; } } @@ -159,12 +160,12 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s", names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired, errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("testing DsCrackNames (matrix) with name '%s' from format: %d desired format:%d failed - %s", names[0].str, r.in.req.req1.format_offered, r.in.req.req1.format_desired, win_errstr(r.out.result)); - ret = False; + ret = false; } if (!ret) { @@ -190,26 +191,26 @@ static BOOL test_DsCrackNamesMatrix(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } else if (n_matrix[i][j] == NULL && formats[j] == DRSUAPI_DS_NAME_FORMAT_SERVICE_PRINCIPAL) { } else if (n_matrix[i][j] == NULL && n_from[j] != NULL) { printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); - ret = False; + ret = false; } else if (n_matrix[i][j] != NULL && n_from[j] == NULL) { printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); - ret = False; + ret = false; } else if (strcmp(n_matrix[i][j], n_from[j]) != 0) { printf("dcerpc_drsuapi_DsCrackNames mismatch - from %d to %d: %s should be %s\n", formats[i], formats[j], n_matrix[i][j], n_from[j]); - ret = False; + ret = false; } } } return ret; } -BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct DsPrivate *priv) { NTSTATUS status; struct drsuapi_DsCrackNames r; struct drsuapi_DsNameString names[1]; - BOOL ret = True; + bool ret = true; const char *dns_domain; const char *nt4_domain; const char *FQDN_1779_name; @@ -253,13 +254,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; + ret = false; } if (!ret) { @@ -281,13 +282,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; + ret = false; } if (!ret) { @@ -310,13 +311,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; + ret = false; } if (!ret) { @@ -334,7 +335,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("local Round trip on canonical name failed: %s != %s!\n", realm_canonical, talloc_asprintf(mem_ctx, "%s/", dns_domain)); - return False; + return false; }; realm_canonical_ex = ldb_dn_canonical_ex_string(mem_ctx, realm_dn); @@ -344,7 +345,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("local Round trip on canonical ex name failed: %s != %s!\n", realm_canonical, talloc_asprintf(mem_ctx, "%s\n", dns_domain)); - return False; + return false; }; r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; @@ -361,13 +362,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; + ret = false; } if (!ret) { @@ -390,13 +391,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; + ret = false; } if (!ret) { @@ -419,13 +420,13 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } else if (r.out.ctr.ctr1->array[0].status != DRSUAPI_DS_NAME_STATUS_OK) { printf("DsCrackNames failed on name - %d\n", r.out.ctr.ctr1->array[0].status); - ret = False; + ret = false; } if (!ret) { @@ -434,7 +435,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (strcmp(priv->domain_dns_name, r.out.ctr.ctr1->array[0].dns_domain_name) != 0) { printf("DsCrackNames failed to return same DNS name - expected %s got %s\n", priv->domain_dns_name, r.out.ctr.ctr1->array[0].dns_domain_name); - return False; + return false; } FQDN_1779_dn = ldb_dn_new(mem_ctx, ldb, FQDN_1779_name); @@ -462,7 +463,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, enum drsuapi_DsNameStatus status; enum drsuapi_DsNameStatus alternate_status; enum drsuapi_DsNameFlags flags; - BOOL skip; + bool skip; } crack[] = { { .format_offered = DRSUAPI_DS_NAME_FORMAT_USER_PRINCIPAL, @@ -588,7 +589,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, .comment = "display name for Microsoft Support Account", .status = DRSUAPI_DS_NAME_STATUS_OK, .alternate_status = DRSUAPI_DS_NAME_STATUS_NOT_UNIQUE, - .skip = lp_parm_bool(-1, "torture", "samba4", False) + .skip = lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false) }, { .format_offered = DRSUAPI_DS_NAME_FORMAT_GUID, @@ -814,6 +815,27 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND }, { + .format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, + .format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779, + .comment = "NT AUTHORITY\\ -> DN", + .str = "NT AUTHORITY\\", + .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND + }, + { + .format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, + .format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779, + .comment = "NT AUTHORITY\\ANONYMOUS LOGON -> DN", + .str = "NT AUTHORITY\\ANONYMOUS LOGON", + .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND + }, + { + .format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, + .format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779, + .comment = "NT AUTHORITY\\SYSTEM -> DN", + .str = "NT AUTHORITY\\SYSTEM", + .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND + }, + { .format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY, .format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, .comment = "BUITIN SID -> NT4 account", @@ -848,6 +870,20 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, }, { .format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY, + .format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, + .str = SID_NT_ANONYMOUS, + .comment = "NT Anonymous SID -> NT4 Account", + .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND + }, + { + .format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY, + .format_desired = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT, + .str = SID_NT_SYSTEM, + .comment = "NT SYSTEM SID -> NT4 Account", + .status = DRSUAPI_DS_NAME_STATUS_NOT_FOUND + }, + { + .format_offered = DRSUAPI_DS_NAME_FORMAT_SID_OR_SID_HISTORY, .format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779, .comment = "Domain SID -> DN", .str = dom_sid, @@ -905,10 +941,10 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); } printf("dcerpc_drsuapi_DsCrackNames failed on %s - %s\n", comment, errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } else if (r.out.ctr.ctr1->array[0].status != crack[i].status) { if (crack[i].alternate_status) { if (r.out.ctr.ctr1->array[0].status != crack[i].alternate_status) { @@ -917,14 +953,14 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, crack[i].status, crack[i].alternate_status, comment); - ret = False; + ret = false; } } else { printf("DsCrackNames unexpected status %d, wanted %d on: %s\n", r.out.ctr.ctr1->array[0].status, crack[i].status, comment); - ret = False; + ret = false; } } else if (crack[i].expected_str && (strcmp(r.out.ctr.ctr1->array[0].result_name, @@ -934,7 +970,7 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("DsCrackNames failed - got %s, expected %s on %s\n", r.out.ctr.ctr1->array[0].result_name, crack[i].expected_str, comment); - ret = False; + ret = false; } else { printf("(warning) DsCrackNames returned different case - got %s, expected %s on %s\n", r.out.ctr.ctr1->array[0].result_name, @@ -946,14 +982,14 @@ BOOL test_DsCrackNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("DsCrackNames failed - got DNS name %s, expected %s on %s\n", r.out.ctr.ctr1->array[0].result_name, crack[i].expected_str, comment); - ret = False; + ret = false; } } } if (!test_DsCrackNamesMatrix(p, mem_ctx, priv, FQDN_1779_name, user_principal_name, service_principal_name)) { - ret = False; + ret = false; } return ret; diff --git a/source4/torture/rpc/dssetup.c b/source4/torture/rpc/dssetup.c index c80e37eb7d..aa5f12eb92 100644 --- a/source4/torture/rpc/dssetup.c +++ b/source4/torture/rpc/dssetup.c @@ -25,56 +25,40 @@ #include "torture/rpc/rpc.h" -BOOL test_DsRoleGetPrimaryDomainInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +bool test_DsRoleGetPrimaryDomainInformation_ext(struct torture_context *tctx, + struct dcerpc_pipe *p, + NTSTATUS ext_status) { struct dssetup_DsRoleGetPrimaryDomainInformation r; NTSTATUS status; - BOOL ret = True; int i; - printf("\ntesting DsRoleGetPrimaryDomainInformation\n"); - for (i=DS_ROLE_BASIC_INFORMATION; i <= DS_ROLE_OP_STATUS; i++) { r.in.level = i; + torture_comment(tctx, "dcerpc_dssetup_DsRoleGetPrimaryDomainInformation level %d\n", i); - status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - const char *errstr = nt_errstr(status); - if (NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { - errstr = dcerpc_errstr(mem_ctx, p->last_fault_code); - } - printf("dcerpc_dssetup_DsRoleGetPrimaryDomainInformation level %d failed - %s\n", - i, errstr); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("DsRoleGetPrimaryDomainInformation level %d failed - %s\n", - i, win_errstr(r.out.result)); - ret = False; + status = dcerpc_dssetup_DsRoleGetPrimaryDomainInformation(p, tctx, &r); + torture_assert_ntstatus_equal(tctx, ext_status, status, "DsRoleGetPrimaryDomainInformation failed"); + if (NT_STATUS_IS_OK(ext_status)) { + torture_assert_werr_ok(tctx, r.out.result, "DsRoleGetPrimaryDomainInformation failed"); } } - return ret; + return true; } -BOOL torture_rpc_dssetup(struct torture_context *torture) +bool test_DsRoleGetPrimaryDomainInformation(struct torture_context *tctx, + struct dcerpc_pipe *p) { - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - - mem_ctx = talloc_init("torture_rpc_dssetup"); - - status = torture_rpc_connection(torture, &p, &ndr_table_dssetup); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - - return False; - } + return test_DsRoleGetPrimaryDomainInformation_ext(tctx, p, NT_STATUS_OK); +} - ret &= test_DsRoleGetPrimaryDomainInformation(p, mem_ctx); +struct torture_suite *torture_rpc_dssetup(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, "DSSETUP"); + struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite, "dssetup", &ndr_table_dssetup); - talloc_free(mem_ctx); + torture_rpc_tcase_add_test(tcase, "DsRoleGetPrimaryDomainInformation", test_DsRoleGetPrimaryDomainInformation); - return ret; + return suite; } diff --git a/source4/torture/rpc/dssync.c b/source4/torture/rpc/dssync.c index 6357fa9ee5..15125ac365 100644 --- a/source4/torture/rpc/dssync.c +++ b/source4/torture/rpc/dssync.c @@ -32,6 +32,7 @@ #include "auth/credentials/credentials.h" #include "libcli/auth/libcli_auth.h" #include "auth/gensec/gensec.h" +#include "param/param.h" struct DsSyncBindInfo { struct dcerpc_pipe *pipe; @@ -83,7 +84,7 @@ static struct DsSyncTest *test_create_context(TALLOC_CTX *mem_ctx) struct DsSyncTest *ctx; struct drsuapi_DsBindInfo28 *our_bind_info28; struct drsuapi_DsBindInfoCtr *our_bind_info_ctr; - const char *binding = lp_parm_string(-1, "torture", "binding"); + const char *binding = lp_parm_string(global_loadparm, NULL, "torture", "binding"); ctx = talloc_zero(mem_ctx, struct DsSyncTest); if (!ctx) return NULL; @@ -148,7 +149,7 @@ static struct DsSyncTest *test_create_context(TALLOC_CTX *mem_ctx) our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_ADDENTRYREPLY_V3; our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_GETCHGREPLY_V7; our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_VERIFY_OBJECT; - if (lp_parm_bool(-1,"dssync","xpress",False)) { + if (lp_parm_bool(global_loadparm, NULL, "dssync", "xpress", false)) { our_bind_info28->supported_extensions |= DRSUAPI_SUPPORTED_EXTENSION_XPRESS_COMPRESS; } our_bind_info28->site_guid = GUID_zero(); @@ -172,10 +173,10 @@ static struct DsSyncTest *test_create_context(TALLOC_CTX *mem_ctx) return ctx; } -static BOOL _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncBindInfo *b) +static bool _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncBindInfo *b) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct event_context *event = NULL; status = dcerpc_pipe_connect_b(ctx, @@ -185,7 +186,7 @@ static BOOL _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credent if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status)); - return False; + return false; } status = dcerpc_drsuapi_DsBind(b->pipe, ctx, &b->req); @@ -195,10 +196,10 @@ static BOOL _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credent errstr = dcerpc_errstr(ctx, b->pipe->last_fault_code); } printf("dcerpc_drsuapi_DsBind failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(b->req.out.result)) { printf("DsBind failed - %s\n", win_errstr(b->req.out.result)); - ret = False; + ret = false; } ZERO_STRUCT(b->peer_bind_info28); @@ -222,15 +223,15 @@ static BOOL _test_DsBind(struct DsSyncTest *ctx, struct cli_credentials *credent return ret; } -static BOOL test_LDAPBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncLDAPInfo *l) +static bool test_LDAPBind(struct DsSyncTest *ctx, struct cli_credentials *credentials, struct DsSyncLDAPInfo *l) { NTSTATUS status; - BOOL ret = True; + bool ret = true; status = torture_ldap_connection(ctx, &l->conn, ctx->ldap_url); if (!NT_STATUS_IS_OK(status)) { printf("failed to connect to LDAP: %s\n", ctx->ldap_url); - return False; + return false; } printf("connected to LDAP: %s\n", ctx->ldap_url); @@ -238,19 +239,19 @@ static BOOL test_LDAPBind(struct DsSyncTest *ctx, struct cli_credentials *creden status = torture_ldap_bind_sasl(l->conn, credentials); if (!NT_STATUS_IS_OK(status)) { printf("failed to bind to LDAP:\n"); - return False; + return false; } printf("bound to LDAP.\n"); return ret; } -static BOOL test_GetInfo(struct DsSyncTest *ctx) +static bool test_GetInfo(struct DsSyncTest *ctx) { NTSTATUS status; struct drsuapi_DsCrackNames r; struct drsuapi_DsNameString names[1]; - BOOL ret = True; + bool ret = true; struct cldap_socket *cldap = cldap_socket_init(ctx, NULL); struct cldap_netlogon search; @@ -264,7 +265,7 @@ static BOOL test_GetInfo(struct DsSyncTest *ctx) r.in.req.req1.format_flags = DRSUAPI_DS_NAME_FLAG_NO_FLAGS; r.in.req.req1.format_offered = DRSUAPI_DS_NAME_FORMAT_NT4_ACCOUNT; r.in.req.req1.format_desired = DRSUAPI_DS_NAME_FORMAT_FQDN_1779; - names[0].str = talloc_asprintf(ctx, "%s\\", lp_workgroup()); + names[0].str = talloc_asprintf(ctx, "%s\\", lp_workgroup(global_loadparm)); status = dcerpc_drsuapi_DsCrackNames(ctx->admin.drsuapi.pipe, ctx, &r); if (!NT_STATUS_IS_OK(status)) { @@ -273,10 +274,10 @@ static BOOL test_GetInfo(struct DsSyncTest *ctx) errstr = dcerpc_errstr(ctx, ctx->admin.drsuapi.pipe->last_fault_code); } printf("dcerpc_drsuapi_DsCrackNames failed - %s\n", errstr); - return False; + return false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsCrackNames failed - %s\n", win_errstr(r.out.result)); - return False; + return false; } ctx->domain_dn = r.out.ctr.ctr1->array[0].result_name; @@ -419,17 +420,17 @@ static void test_analyse_objects(struct DsSyncTest *ctx, static uint32_t object_id; const char *save_values_dir; - if (!lp_parm_bool(-1,"dssync","print_pwd_blobs", false)) { + if (!lp_parm_bool(global_loadparm, NULL,"dssync","print_pwd_blobs", false)) { return; } - save_values_dir = lp_parm_string(-1,"dssync","save_pwd_blobs_dir"); + save_values_dir = lp_parm_string(global_loadparm, NULL, "dssync", "save_pwd_blobs_dir"); for (; cur; cur = cur->next_object) { const char *dn; struct dom_sid *sid = NULL; uint32_t rid = 0; - BOOL dn_printed = False; + bool dn_printed = false; uint32_t i; if (!cur->object.identifier) continue; @@ -503,7 +504,7 @@ static void test_analyse_objects(struct DsSyncTest *ctx, if (!dn_printed) { object_id++; DEBUG(0,("DN[%u] %s\n", object_id, dn)); - dn_printed = True; + dn_printed = true; } DEBUGADD(0,("ATTR: %s enc.length=%lu plain.length=%lu\n", name, (long)enc_data->length, (long)plain_data.length)); @@ -530,10 +531,10 @@ static void test_analyse_objects(struct DsSyncTest *ctx, } } -static BOOL test_FetchData(struct DsSyncTest *ctx) +static bool test_FetchData(struct DsSyncTest *ctx) { NTSTATUS status; - BOOL ret = True; + bool ret = true; int i, y = 0; uint64_t highest_usn = 0; const char *partition = NULL; @@ -559,17 +560,17 @@ static BOOL test_FetchData(struct DsSyncTest *ctx) ZERO_STRUCT(null_guid); ZERO_STRUCT(null_sid); - partition = lp_parm_string(-1, "dssync", "partition"); + partition = lp_parm_string(global_loadparm, NULL, "dssync", "partition"); if (partition == NULL) { partition = ctx->domain_dn; printf("dssync:partition not specified, defaulting to %s.\n", ctx->domain_dn); } - highest_usn = lp_parm_int(-1, "dssync", "highest_usn", 0); + highest_usn = lp_parm_int(global_loadparm, NULL, "dssync", "highest_usn", 0); - array[0].level = lp_parm_int(-1, "dssync", "get_nc_changes_level", array[0].level); + array[0].level = lp_parm_int(global_loadparm, NULL, "dssync", "get_nc_changes_level", array[0].level); - if (lp_parm_bool(-1,"dssync","print_pwd_blobs",False)) { + if (lp_parm_bool(global_loadparm, NULL, "dssync", "print_pwd_blobs", false)) { const struct samr_Password *nthash; nthash = cli_credentials_get_nt_hash(ctx->new_dc.credentials, ctx); if (nthash) { @@ -581,7 +582,7 @@ static BOOL test_FetchData(struct DsSyncTest *ctx) &gensec_skey); if (!NT_STATUS_IS_OK(status)) { printf("failed to get gensec session key: %s\n", nt_errstr(status)); - return False; + return false; } for (i=0; i < ARRAY_SIZE(array); i++) { @@ -605,10 +606,10 @@ static BOOL test_FetchData(struct DsSyncTest *ctx) r.in.req.req5.highwatermark.highest_usn = highest_usn; r.in.req.req5.uptodateness_vector = NULL; r.in.req.req5.replica_flags = 0; - if (lp_parm_bool(-1,"dssync","compression",False)) { + if (lp_parm_bool(global_loadparm, NULL, "dssync", "compression", false)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(-1,"dssync","neighbour_writeable",True)) { + if (lp_parm_bool(global_loadparm, NULL, "dssync", "neighbour_writeable", true)) { r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } r.in.req.req5.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP @@ -636,10 +637,10 @@ static BOOL test_FetchData(struct DsSyncTest *ctx) r.in.req.req8.highwatermark.highest_usn = highest_usn; r.in.req.req8.uptodateness_vector = NULL; r.in.req.req8.replica_flags = 0; - if (lp_parm_bool(-1,"dssync","compression",False)) { + if (lp_parm_bool(global_loadparm, NULL, "dssync", "compression", false)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_COMPRESS_CHANGES; } - if (lp_parm_bool(-1,"dssync","neighbour_writeable",True)) { + if (lp_parm_bool(global_loadparm, NULL, "dssync", "neighbour_writeable", true)) { r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_WRITEABLE; } r.in.req.req8.replica_flags |= DRSUAPI_DS_REPLICA_NEIGHBOUR_SYNC_ON_STARTUP @@ -685,16 +686,16 @@ static BOOL test_FetchData(struct DsSyncTest *ctx) errstr = dcerpc_errstr(ctx, ctx->new_dc.drsuapi.pipe->last_fault_code); } printf("dcerpc_drsuapi_DsGetNCChanges failed - %s\n", errstr); - ret = False; + ret = false; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsGetNCChanges failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } - if (ret == True && *r.out.level == 1) { + if (ret == true && *r.out.level == 1) { out_level = 1; ctr1 = &r.out.ctr.ctr1; - } else if (ret == True && *r.out.level == 2) { + } else if (ret == true && *r.out.level == 2) { out_level = 1; ctr1 = r.out.ctr.ctr2.ctr.mszip1.ctr1; } @@ -712,10 +713,10 @@ static BOOL test_FetchData(struct DsSyncTest *ctx) } } - if (ret == True && *r.out.level == 6) { + if (ret == true && *r.out.level == 6) { out_level = 6; ctr6 = &r.out.ctr.ctr6; - } else if (ret == True && *r.out.level == 7 + } else if (ret == true && *r.out.level == 7 && r.out.ctr.ctr7.level == 6 && r.out.ctr.ctr7.type == DRSUAPI_COMPRESSION_TYPE_MSZIP) { out_level = 6; @@ -742,10 +743,10 @@ static BOOL test_FetchData(struct DsSyncTest *ctx) return ret; } -static BOOL test_FetchNT4Data(struct DsSyncTest *ctx) +static bool test_FetchNT4Data(struct DsSyncTest *ctx) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct drsuapi_DsGetNT4ChangeLog r; struct GUID null_guid; struct dom_sid null_sid; @@ -759,8 +760,8 @@ static BOOL test_FetchNT4Data(struct DsSyncTest *ctx) r.in.bind_handle = &ctx->new_dc.drsuapi.bind_handle; r.in.level = 1; - r.in.req.req1.unknown1 = lp_parm_int(-1, "dssync", "nt4-1", 3); - r.in.req.req1.unknown2 = lp_parm_int(-1, "dssync", "nt4-2", 0x00004000); + r.in.req.req1.unknown1 = lp_parm_int(global_loadparm, NULL, "dssync", "nt4-1", 3); + r.in.req.req1.unknown2 = lp_parm_int(global_loadparm, NULL, "dssync", "nt4-2", 0x00004000); while (1) { r.in.req.req1.length = cookie.length; @@ -773,16 +774,16 @@ static BOOL test_FetchNT4Data(struct DsSyncTest *ctx) errstr = dcerpc_errstr(ctx, ctx->new_dc.drsuapi.pipe->last_fault_code); } printf("dcerpc_drsuapi_DsGetNT4ChangeLog failed - %s\n", errstr); - ret = False; + ret = false; } else if (W_ERROR_EQUAL(r.out.result, WERR_INVALID_DOMAIN_ROLE)) { printf("DsGetNT4ChangeLog not supported by target server\n"); break; } else if (!W_ERROR_IS_OK(r.out.result)) { printf("DsGetNT4ChangeLog failed - %s\n", win_errstr(r.out.result)); - ret = False; + ret = false; } else if (r.out.level != 1) { printf("DsGetNT4ChangeLog unknown level - %u\n", r.out.level); - ret = False; + ret = false; } else if (NT_STATUS_IS_OK(r.out.info.info1.status)) { } else if (NT_STATUS_EQUAL(r.out.info.info1.status, STATUS_MORE_ENTRIES)) { cookie.length = r.out.info.info1.length1; @@ -790,7 +791,7 @@ static BOOL test_FetchNT4Data(struct DsSyncTest *ctx) continue; } else { printf("DsGetNT4ChangeLog failed - %s\n", nt_errstr(r.out.info.info1.status)); - ret = False; + ret = false; } break; @@ -799,9 +800,9 @@ static BOOL test_FetchNT4Data(struct DsSyncTest *ctx) return ret; } -BOOL torture_rpc_dssync(struct torture_context *torture) +bool torture_rpc_dssync(struct torture_context *torture) { - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx; struct DsSyncTest *ctx; diff --git a/source4/torture/rpc/echo.c b/source4/torture/rpc/echo.c index edc35c0aa7..5c027d3299 100644 --- a/source4/torture/rpc/echo.c +++ b/source4/torture/rpc/echo.c @@ -78,8 +78,8 @@ static bool test_echodata(struct torture_context *tctx, len = 1 + (random() % 5000); } - data_in = talloc_size(tctx, len); - data_out = talloc_size(tctx, len); + data_in = talloc_array(tctx, uint8_t, len); + data_out = talloc_array(tctx, uint8_t, len); for (i=0;i<len;i++) { data_in[i] = i; } @@ -159,7 +159,7 @@ static bool test_sinkdata(struct torture_context *tctx, len = 200000 + (random() % 5000); } - data_in = talloc_size(tctx, len); + data_in = talloc_array(tctx, uint8_t, len); for (i=0;i<len;i++) { data_in[i] = i+1; } @@ -230,7 +230,7 @@ static bool test_sleep(struct torture_context *tctx, #define ASYNC_COUNT 3 struct rpc_request *req[ASYNC_COUNT]; struct echo_TestSleep r[ASYNC_COUNT]; - BOOL done[ASYNC_COUNT]; + bool done[ASYNC_COUNT]; struct timeval snd[ASYNC_COUNT]; struct timeval rcv[ASYNC_COUNT]; struct timeval diff[ASYNC_COUNT]; @@ -240,10 +240,10 @@ static bool test_sleep(struct torture_context *tctx, if (torture_setting_bool(tctx, "quick", false)) { torture_skip(tctx, "TestSleep disabled - use \"torture:quick=no\" to enable\n"); } - torture_comment(tctx, "Testing TestSleep - use \"torture:quick=no\" to disable\n"); + torture_comment(tctx, "Testing TestSleep - use \"torture:quick=yes\" to disable\n"); for (i=0;i<ASYNC_COUNT;i++) { - done[i] = False; + done[i] = false; snd[i] = timeval_current(); rcv[i] = timeval_zero(); r[i].in.seconds = ASYNC_COUNT-i; @@ -256,15 +256,15 @@ static bool test_sleep(struct torture_context *tctx, torture_assert(tctx, event_loop_once(ctx) == 0, "Event context loop failed"); for (i=0;i<ASYNC_COUNT;i++) { - if (done[i] == False && req[i]->state == RPC_REQUEST_DONE) { + if (done[i] == false && req[i]->state == RPC_REQUEST_DONE) { int rounded_tdiff; total_done++; - done[i] = True; + done[i] = true; rcv[i] = timeval_current(); diff[i] = timeval_until(&snd[i], &rcv[i]); rounded_tdiff = (int)(0.5 + diff[i].tv_sec + (1.0e-6*diff[i].tv_usec)); status = dcerpc_ndr_request_recv(req[i]); - printf("rounded_tdiff=%d\n", rounded_tdiff); + torture_comment(tctx, "rounded_tdiff=%d\n", rounded_tdiff); torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "TestSleep(%d) failed", i)); torture_assert(tctx, r[i].out.result == r[i].in.seconds, @@ -287,7 +287,7 @@ static bool test_sleep(struct torture_context *tctx, } } } - printf("\n"); + torture_comment(tctx, "\n"); return true; } @@ -393,7 +393,7 @@ static bool test_timeout(struct torture_context *tctx, torture_comment(tctx, "Failed to send async sleep request\n"); goto failed; } - req->ignore_timeout = True; + req->ignore_timeout = true; status = dcerpc_ndr_request_recv(req); torture_assert_ntstatus_equal(tctx, status, NT_STATUS_IO_TIMEOUT, @@ -412,7 +412,7 @@ static bool test_timeout(struct torture_context *tctx, torture_comment(tctx, "Failed to send async sleep request\n"); goto failed; } - req->ignore_timeout = True; + req->ignore_timeout = true; status = dcerpc_ndr_request_recv(req); torture_assert_ntstatus_equal(tctx, status, NT_STATUS_IO_TIMEOUT, "request should have timed out"); @@ -427,10 +427,10 @@ failed: } -struct torture_suite *torture_rpc_echo(void) +struct torture_suite *torture_rpc_echo(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create( - talloc_autofree_context(), "ECHO"); + mem_ctx, "ECHO"); struct torture_rpc_tcase *tcase; tcase = torture_suite_add_rpc_iface_tcase(suite, "echo", diff --git a/source4/torture/rpc/epmapper.c b/source4/torture/rpc/epmapper.c index f6f8e66369..830b77aed9 100644 --- a/source4/torture/rpc/epmapper.c +++ b/source4/torture/rpc/epmapper.c @@ -39,7 +39,7 @@ static void display_tower(TALLOC_CTX *mem_ctx, struct epm_tower *twr) } -static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct epm_twr_t *twr) { NTSTATUS status; @@ -131,7 +131,7 @@ static BOOL test_Map(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, /* FIXME: Extend to do other protocols as well (ncacn_unix_stream, ncalrpc) */ - return True; + return true; } static bool test_Lookup(struct torture_context *tctx, @@ -186,7 +186,7 @@ static bool test_Lookup(struct torture_context *tctx, return true; } -static BOOL test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct epm_entry_t *entries) +static bool test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct epm_entry_t *entries) { NTSTATUS status; struct epm_Delete r; @@ -197,15 +197,15 @@ static BOOL test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct epm_e status = dcerpc_epm_Delete(p, mem_ctx, &r); if (NT_STATUS_IS_ERR(status)) { printf("Delete failed - %s\n", nt_errstr(status)); - return False; + return false; } if (r.out.result != 0) { printf("Delete failed - %d\n", r.out.result); - return False; + return false; } - return True; + return true; } static bool test_Insert(struct torture_context *tctx, diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c index 1c72625f73..c1d863454c 100644 --- a/source4/torture/rpc/eventlog.c +++ b/source4/torture/rpc/eventlog.c @@ -125,7 +125,7 @@ static bool test_ReadEventLog(struct torture_context *tctx, /* Now read the actual record */ r.in.number_of_bytes = *r.out.real_size; - r.out.data = talloc_size(tctx, r.in.number_of_bytes); + r.out.data = talloc_array(tctx, uint8_t, r.in.number_of_bytes); status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r); @@ -192,10 +192,6 @@ static bool test_ClearEventLog(struct torture_context *tctx, struct eventlog_CloseEventLog cr; struct policy_handle handle; - if (!torture_setting_bool(tctx, "dangerous", false)) { - torture_skip(tctx, "ClearEventLog test disabled - enable dangerous tests to use"); - } - if (!get_policy_handle(tctx, p, &handle)) return false; @@ -233,17 +229,20 @@ static bool test_OpenEventLog(struct torture_context *tctx, return true; } -struct torture_suite *torture_rpc_eventlog(void) +struct torture_suite *torture_rpc_eventlog(TALLOC_CTX *mem_ctx) { struct torture_suite *suite; struct torture_rpc_tcase *tcase; + struct torture_test *test; - suite = torture_suite_create(talloc_autofree_context(), "EVENTLOG"); + suite = torture_suite_create(mem_ctx, "EVENTLOG"); tcase = torture_suite_add_rpc_iface_tcase(suite, "eventlog", &ndr_table_eventlog); torture_rpc_tcase_add_test(tcase, "OpenEventLog", test_OpenEventLog); - torture_rpc_tcase_add_test(tcase, "ClearEventLog", test_ClearEventLog); + test = torture_rpc_tcase_add_test(tcase, "ClearEventLog", + test_ClearEventLog); + test->dangerous = true; torture_rpc_tcase_add_test(tcase, "GetNumRecords", test_GetNumRecords); torture_rpc_tcase_add_test(tcase, "ReadEventLog", test_ReadEventLog); torture_rpc_tcase_add_test(tcase, "FlushEventLog", test_FlushEventLog); diff --git a/source4/torture/rpc/initshutdown.c b/source4/torture/rpc/initshutdown.c index 77b86ea3a1..9f6f1735ee 100644 --- a/source4/torture/rpc/initshutdown.c +++ b/source4/torture/rpc/initshutdown.c @@ -51,16 +51,12 @@ static bool test_Abort(struct torture_context *tctx, } static bool test_Init(struct torture_context *tctx, - struct dcerpc_pipe *p) + struct dcerpc_pipe *p) { struct initshutdown_Init r; NTSTATUS status; uint16_t hostname = 0x0; - if (!torture_setting_bool(tctx, "dangerous", false)) - torture_skip(tctx, - "initshutdown tests disabled - enable dangerous tests to use"); - r.in.hostname = &hostname; r.in.message = talloc(tctx, struct initshutdown_String); init_initshutdown_String(tctx, r.in.message, "spottyfood"); @@ -83,10 +79,6 @@ static bool test_InitEx(struct torture_context *tctx, NTSTATUS status; uint16_t hostname = 0x0; - if (!torture_setting_bool(tctx, "dangerous", false)) - torture_skip(tctx, - "initshutdown tests disabled - enable dangerous tests to use"); - r.in.hostname = &hostname; r.in.message = talloc(tctx, struct initshutdown_String); init_initshutdown_String(tctx, r.in.message, "spottyfood"); @@ -109,12 +101,15 @@ struct torture_suite *torture_rpc_initshutdown(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "INITSHUTDOWN"); struct torture_rpc_tcase *tcase; + struct torture_test *test; tcase = torture_suite_add_rpc_iface_tcase(suite, "initshutdown", - &ndr_table_initshutdown); + &ndr_table_initshutdown); - torture_rpc_tcase_add_test(tcase, "Init", test_Init); - torture_rpc_tcase_add_test(tcase, "InitEx", test_InitEx); + test = torture_rpc_tcase_add_test(tcase, "Init", test_Init); + test->dangerous = true; + test = torture_rpc_tcase_add_test(tcase, "InitEx", test_InitEx); + test->dangerous = true; return suite; } diff --git a/source4/torture/rpc/join.c b/source4/torture/rpc/join.c index 23c43c525e..d0ad97110a 100644 --- a/source4/torture/rpc/join.c +++ b/source4/torture/rpc/join.c @@ -8,7 +8,7 @@ #define TORTURE_NETBIOS_NAME "smbtorturejoin" -BOOL torture_rpc_join(struct torture_context *torture) +bool torture_rpc_join(struct torture_context *torture) { NTSTATUS status; struct test_join *tj; @@ -24,7 +24,7 @@ BOOL torture_rpc_join(struct torture_context *torture) if (!tj) { DEBUG(0, ("%s failed to join domain as workstation\n", TORTURE_NETBIOS_NAME)); - return False; + return false; } status = smbcli_full_connection(tj, &cli, host, @@ -34,7 +34,7 @@ BOOL torture_rpc_join(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n", TORTURE_NETBIOS_NAME)); - return False; + return false; } smbcli_tdis(cli); @@ -48,7 +48,7 @@ BOOL torture_rpc_join(struct torture_context *torture) if (!tj) { DEBUG(0, ("%s failed to join domain as domain controller\n", TORTURE_NETBIOS_NAME)); - return False; + return false; } status = smbcli_full_connection(tj, &cli, host, @@ -58,7 +58,7 @@ BOOL torture_rpc_join(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("%s failed to connect to IPC$ with workstation credentials\n", TORTURE_NETBIOS_NAME)); - return False; + return false; } smbcli_tdis(cli); @@ -66,6 +66,6 @@ BOOL torture_rpc_join(struct torture_context *torture) /* Leave domain. */ torture_leave_domain(tj); - return True; + return true; } diff --git a/source4/torture/rpc/lsa.c b/source4/torture/rpc/lsa.c index cfdf483f8d..1250743955 100644 --- a/source4/torture/rpc/lsa.c +++ b/source4/torture/rpc/lsa.c @@ -27,13 +27,14 @@ #include "libcli/security/security.h" #include "libcli/auth/libcli_auth.h" #include "torture/rpc/rpc.h" +#include "param/param.h" static void init_lsa_String(struct lsa_String *name, const char *s) { name->string = s; } -static BOOL test_OpenPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_OpenPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { struct lsa_ObjectAttribute attr; struct policy_handle handle; @@ -66,17 +67,17 @@ static BOOL test_OpenPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) { printf("not considering %s to be an error\n", nt_errstr(status)); - return True; + return true; } printf("OpenPolicy failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -BOOL test_lsa_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_lsa_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle **handle) { struct lsa_ObjectAttribute attr; @@ -88,7 +89,7 @@ BOOL test_lsa_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, *handle = talloc(mem_ctx, struct policy_handle); if (!*handle) { - return False; + return false; } qos.len = 0; @@ -115,19 +116,19 @@ BOOL test_lsa_OpenPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("not considering %s to be an error\n", nt_errstr(status)); talloc_free(*handle); *handle = NULL; - return True; + return true; } printf("OpenPolicy2 failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_LookupNames(struct dcerpc_pipe *p, +static bool test_LookupNames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, - struct lsa_TransNameArray *tnames) + struct lsa_TransNameArray *tnames) { struct lsa_LookupNames r; struct lsa_TransSidArray sids; @@ -156,17 +157,106 @@ static BOOL test_LookupNames(struct dcerpc_pipe *p, r.out.sids = &sids; status = dcerpc_lsa_LookupNames(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { + if (!NT_STATUS_IS_OK(status)) { + printf("LookupNames failed - %s\n", nt_errstr(status)); + return false; + } + + printf("\n"); + + return true; +} + +static bool test_LookupNames_bogus(struct dcerpc_pipe *p, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle) +{ + struct lsa_LookupNames r; + struct lsa_TransSidArray sids; + struct lsa_String *names; + uint32_t count = 0; + NTSTATUS status; + int i; + + struct lsa_TranslatedName name; + struct lsa_TransNameArray tnames; + + tnames.names = &name; + tnames.count = 1; + name.name.string = "NT AUTHORITY\\BOGUS"; + + printf("\nTesting LookupNames with bogus names\n"); + + sids.count = 0; + sids.sids = NULL; + + names = talloc_array(mem_ctx, struct lsa_String, tnames.count); + for (i=0;i<tnames.count;i++) { + init_lsa_String(&names[i], tnames.names[i].name.string); + } + + r.in.handle = handle; + r.in.num_names = tnames.count; + r.in.names = names; + r.in.sids = &sids; + r.in.level = 1; + r.in.count = &count; + r.out.count = &count; + r.out.sids = &sids; + + status = dcerpc_lsa_LookupNames(p, mem_ctx, &r); + if (!NT_STATUS_EQUAL(status, NT_STATUS_NONE_MAPPED)) { printf("LookupNames failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("\n"); - return True; + return true; } -static BOOL test_LookupNames2(struct dcerpc_pipe *p, +static bool test_LookupNames_wellknown(struct dcerpc_pipe *p, + TALLOC_CTX *mem_ctx, + struct policy_handle *handle) +{ + struct lsa_TranslatedName name; + struct lsa_TransNameArray tnames; + bool ret = true; + + printf("Testing LookupNames with well known names\n"); + + tnames.names = &name; + tnames.count = 1; + name.name.string = "NT AUTHORITY\\SYSTEM"; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); + + name.name.string = "NT AUTHORITY\\ANONYMOUS LOGON"; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); + + name.name.string = "NT AUTHORITY\\Authenticated Users"; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); + + name.name.string = "NT AUTHORITY"; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); + + name.name.string = "NT AUTHORITY\\"; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); + + name.name.string = "BUILTIN\\"; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); + + name.name.string = "BUILTIN\\Administrators"; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); + + name.name.string = "SYSTEM"; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); + + name.name.string = "Everyone"; + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); + return ret; +} + +static bool test_LookupNames2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_TransNameArray2 *tnames) @@ -200,18 +290,18 @@ static BOOL test_LookupNames2(struct dcerpc_pipe *p, r.out.sids = &sids; status = dcerpc_lsa_LookupNames2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { + if (!NT_STATUS_IS_OK(status)) { printf("LookupNames2 failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("\n"); - return True; + return true; } -static BOOL test_LookupNames3(struct dcerpc_pipe *p, +static bool test_LookupNames3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_TransNameArray2 *tnames) @@ -245,17 +335,17 @@ static BOOL test_LookupNames3(struct dcerpc_pipe *p, r.out.sids = &sids; status = dcerpc_lsa_LookupNames3(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { + if (!NT_STATUS_IS_OK(status)) { printf("LookupNames3 failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("\n"); - return True; + return true; } -static BOOL test_LookupNames4(struct dcerpc_pipe *p, +static bool test_LookupNames4(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct lsa_TransNameArray2 *tnames) { @@ -287,18 +377,18 @@ static BOOL test_LookupNames4(struct dcerpc_pipe *p, r.out.sids = &sids; status = dcerpc_lsa_LookupNames4(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { + if (!NT_STATUS_IS_OK(status)) { printf("LookupNames4 failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("\n"); - return True; + return true; } -static BOOL test_LookupSids(struct dcerpc_pipe *p, +static bool test_LookupSids(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_SidArray *sids) @@ -322,22 +412,22 @@ static BOOL test_LookupSids(struct dcerpc_pipe *p, r.out.names = &names; status = dcerpc_lsa_LookupSids(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { + if (!NT_STATUS_IS_OK(status)) { printf("LookupSids failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("\n"); if (!test_LookupNames(p, mem_ctx, handle, &names)) { - return False; + return false; } - return True; + return true; } -static BOOL test_LookupSids2(struct dcerpc_pipe *p, +static bool test_LookupSids2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_SidArray *sids) @@ -363,25 +453,25 @@ static BOOL test_LookupSids2(struct dcerpc_pipe *p, r.out.names = &names; status = dcerpc_lsa_LookupSids2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { + if (!NT_STATUS_IS_OK(status)) { printf("LookupSids2 failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("\n"); if (!test_LookupNames2(p, mem_ctx, handle, &names)) { - return False; + return false; } if (!test_LookupNames3(p, mem_ctx, handle, &names)) { - return False; + return false; } - return True; + return true; } -static BOOL test_LookupSids3(struct dcerpc_pipe *p, +static bool test_LookupSids3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct lsa_SidArray *sids) { @@ -405,27 +495,27 @@ static BOOL test_LookupSids3(struct dcerpc_pipe *p, r.out.names = &names; status = dcerpc_lsa_LookupSids3(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { + if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) { printf("not considering %s to be an error\n", nt_errstr(status)); - return True; + return true; } printf("LookupSids3 failed - %s - not considered an error\n", nt_errstr(status)); - return False; + return false; } printf("\n"); if (!test_LookupNames4(p, mem_ctx, &names)) { - return False; + return false; } - return True; + return true; } -BOOL test_many_LookupSids(struct dcerpc_pipe *p, +bool test_many_LookupSids(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -462,16 +552,15 @@ BOOL test_many_LookupSids(struct dcerpc_pipe *p, r.out.names = &names; status = dcerpc_lsa_LookupSids(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && - !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { + if (!NT_STATUS_IS_OK(status)) { printf("LookupSids failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("\n"); if (!test_LookupNames(p, mem_ctx, handle, &names)) { - return False; + return false; } } else { struct lsa_LookupSids3 r; @@ -492,18 +581,18 @@ BOOL test_many_LookupSids(struct dcerpc_pipe *p, r.out.names = &names; status = dcerpc_lsa_LookupSids3(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { + if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED) || NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) { printf("not considering %s to be an error\n", nt_errstr(status)); - return True; + return true; } printf("LookupSids3 failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!test_LookupNames4(p, mem_ctx, &names)) { - return False; + return false; } } @@ -511,7 +600,7 @@ BOOL test_many_LookupSids(struct dcerpc_pipe *p, - return True; + return true; } static void lookupsids_cb(struct rpc_request *req) @@ -530,7 +619,7 @@ static void lookupsids_cb(struct rpc_request *req) } } -static BOOL test_LookupSids_async(struct dcerpc_pipe *p, +static bool test_LookupSids_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -541,7 +630,7 @@ static BOOL test_LookupSids_async(struct dcerpc_pipe *p, struct lsa_LookupSids *r; struct rpc_request **req; int i, replies; - BOOL ret = True; + bool ret = true; const int num_async_requests = 50; count = talloc_array(mem_ctx, uint32_t, num_async_requests); @@ -573,7 +662,7 @@ static BOOL test_LookupSids_async(struct dcerpc_pipe *p, req[i] = dcerpc_lsa_LookupSids_send(p, req, &r[i]); if (req[i] == NULL) { - ret = False; + ret = false; break; } @@ -588,13 +677,13 @@ static BOOL test_LookupSids_async(struct dcerpc_pipe *p, talloc_free(req); if (replies < 0) { - ret = False; + ret = false; } return ret; } -static BOOL test_LookupPrivValue(struct dcerpc_pipe *p, +static bool test_LookupPrivValue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *name) @@ -610,13 +699,13 @@ static BOOL test_LookupPrivValue(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupPrivValue(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("\nLookupPrivValue failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_LookupPrivName(struct dcerpc_pipe *p, +static bool test_LookupPrivName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_LUID *luid) @@ -630,13 +719,13 @@ static BOOL test_LookupPrivName(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupPrivName(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("\nLookupPrivName failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, +static bool test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *acct_handle, struct lsa_LUID *luid) @@ -644,7 +733,7 @@ static BOOL test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, NTSTATUS status; struct lsa_RemovePrivilegesFromAccount r; struct lsa_PrivilegeSet privs; - BOOL ret = True; + bool ret = true; printf("Testing RemovePrivilegesFromAccount\n"); @@ -661,13 +750,13 @@ static BOOL test_RemovePrivilegesFromAccount(struct dcerpc_pipe *p, status = dcerpc_lsa_RemovePrivilegesFromAccount(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("RemovePrivilegesFromAccount failed - %s\n", nt_errstr(status)); - return False; + return false; } return ret; } -static BOOL test_AddPrivilegesToAccount(struct dcerpc_pipe *p, +static bool test_AddPrivilegesToAccount(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *acct_handle, struct lsa_LUID *luid) @@ -675,7 +764,7 @@ static BOOL test_AddPrivilegesToAccount(struct dcerpc_pipe *p, NTSTATUS status; struct lsa_AddPrivilegesToAccount r; struct lsa_PrivilegeSet privs; - BOOL ret = True; + bool ret = true; printf("Testing AddPrivilegesToAccount\n"); @@ -691,20 +780,20 @@ static BOOL test_AddPrivilegesToAccount(struct dcerpc_pipe *p, status = dcerpc_lsa_AddPrivilegesToAccount(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("AddPrivilegesToAccount failed - %s\n", nt_errstr(status)); - return False; + return false; } return ret; } -static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p, +static bool test_EnumPrivsAccount(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct policy_handle *acct_handle) { NTSTATUS status; struct lsa_EnumPrivsAccount r; - BOOL ret = True; + bool ret = true; printf("Testing EnumPrivsAccount\n"); @@ -713,7 +802,7 @@ static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p, status = dcerpc_lsa_EnumPrivsAccount(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("EnumPrivsAccount failed - %s\n", nt_errstr(status)); - return False; + return false; } if (r.out.privs && r.out.privs->count > 0) { @@ -732,7 +821,7 @@ static BOOL test_EnumPrivsAccount(struct dcerpc_pipe *p, return ret; } -static BOOL test_Delete(struct dcerpc_pipe *p, +static bool test_Delete(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -745,14 +834,14 @@ static BOOL test_Delete(struct dcerpc_pipe *p, status = dcerpc_lsa_Delete(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Delete failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_CreateAccount(struct dcerpc_pipe *p, +static bool test_CreateAccount(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -773,17 +862,17 @@ static BOOL test_CreateAccount(struct dcerpc_pipe *p, status = dcerpc_lsa_CreateAccount(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("CreateAccount failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!test_Delete(p, mem_ctx, &acct_handle)) { - return False; + return false; } - return True; + return true; } -static BOOL test_DeleteTrustedDomain(struct dcerpc_pipe *p, +static bool test_DeleteTrustedDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_StringLarge name) @@ -800,17 +889,17 @@ static BOOL test_DeleteTrustedDomain(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenTrustedDomainByName(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("lsa_OpenTrustedDomainByName failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!test_Delete(p, mem_ctx, &trustdom_handle)) { - return False; + return false; } - return True; + return true; } -static BOOL test_DeleteTrustedDomainBySid(struct dcerpc_pipe *p, +static bool test_DeleteTrustedDomainBySid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct dom_sid *sid) @@ -824,14 +913,14 @@ static BOOL test_DeleteTrustedDomainBySid(struct dcerpc_pipe *p, status = dcerpc_lsa_DeleteTrustedDomain(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("lsa_DeleteTrustedDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_CreateSecret(struct dcerpc_pipe *p, +static bool test_CreateSecret(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -850,7 +939,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, struct lsa_DATA_BUF_PTR bufp1; struct lsa_DATA_BUF_PTR bufp2; DATA_BLOB enc_key; - BOOL ret = True; + bool ret = true; DATA_BLOB session_key; NTTIME old_mtime, new_mtime; DATA_BLOB blob1, blob2; @@ -880,7 +969,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_CreateSecret(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("CreateSecret failed - %s\n", nt_errstr(status)); - return False; + return false; } r.in.handle = handle; @@ -890,7 +979,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_CreateSecret(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { printf("CreateSecret should have failed OBJECT_NAME_COLLISION - %s\n", nt_errstr(status)); - return False; + return false; } r2.in.handle = handle; @@ -903,13 +992,13 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenSecret(p, mem_ctx, &r2); if (!NT_STATUS_IS_OK(status)) { printf("OpenSecret failed - %s\n", nt_errstr(status)); - return False; + return false; } status = dcerpc_fetch_session_key(p, &session_key); if (!NT_STATUS_IS_OK(status)) { printf("dcerpc_fetch_session_key failed - %s\n", nt_errstr(status)); - return False; + return false; } enc_key = sess_encrypt_string(secret1, &session_key); @@ -926,7 +1015,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_SetSecret(p, mem_ctx, &r3); if (!NT_STATUS_IS_OK(status)) { printf("SetSecret failed - %s\n", nt_errstr(status)); - return False; + return false; } r3.in.sec_handle = &sec_handle; @@ -944,7 +1033,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_SetSecret(p, mem_ctx, &r3); if (!NT_STATUS_EQUAL(status, NT_STATUS_UNKNOWN_REVISION)) { printf("SetSecret should have failed UNKNOWN_REVISION - %s\n", nt_errstr(status)); - ret = False; + ret = false; } data_blob_free(&enc_key); @@ -965,11 +1054,11 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_QuerySecret(p, mem_ctx, &r4); if (!NT_STATUS_IS_OK(status)) { printf("QuerySecret failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { if (r4.out.new_val == NULL || r4.out.new_val->buf == NULL) { printf("No secret buffer returned\n"); - ret = False; + ret = false; } else { blob1.data = r4.out.new_val->buf->data; blob1.length = r4.out.new_val->buf->size; @@ -982,7 +1071,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, if (strcmp(secret1, secret2) != 0) { printf("Returned secret '%s' doesn't match '%s'\n", secret2, secret1); - ret = False; + ret = false; } } } @@ -1001,7 +1090,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_SetSecret(p, mem_ctx, &r5); if (!NT_STATUS_IS_OK(status)) { printf("SetSecret failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } data_blob_free(&enc_key); @@ -1022,14 +1111,14 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_QuerySecret(p, mem_ctx, &r6); if (!NT_STATUS_IS_OK(status)) { printf("QuerySecret failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; secret4 = NULL; } else { if (r6.out.new_val->buf == NULL || r6.out.old_val->buf == NULL || r6.out.new_mtime == NULL || r6.out.old_mtime == NULL) { printf("Both secret buffers and both times not returned\n"); - ret = False; + ret = false; secret4 = NULL; } else { blob1.data = r6.out.new_val->buf->data; @@ -1042,7 +1131,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, if (strcmp(secret3, secret4) != 0) { printf("Returned NEW secret %s doesn't match %s\n", secret4, secret3); - ret = False; + ret = false; } blob1.data = r6.out.old_val->buf->data; @@ -1055,14 +1144,14 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, if (strcmp(secret1, secret2) != 0) { printf("Returned OLD secret %s doesn't match %s\n", secret2, secret1); - ret = False; + ret = false; } if (*r6.out.new_mtime == *r6.out.old_mtime) { printf("Returned secret %s had same mtime for both secrets: %s\n", secname[i], nt_time_string(mem_ctx, *r6.out.new_mtime)); - ret = False; + ret = false; } } } @@ -1081,7 +1170,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_SetSecret(p, mem_ctx, &r7); if (!NT_STATUS_IS_OK(status)) { printf("SetSecret failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } data_blob_free(&enc_key); @@ -1099,26 +1188,26 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_QuerySecret(p, mem_ctx, &r8); if (!NT_STATUS_IS_OK(status)) { printf("QuerySecret failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { if (!r8.out.new_val || !r8.out.old_val) { printf("in/out pointers not returned, despite being set on in for QuerySecret\n"); - ret = False; + ret = false; } else if (r8.out.new_val->buf == NULL) { if (i != LOCAL) { printf("NEW secret buffer not returned after GLOBAL OLD set\n"); - ret = False; + ret = false; } } else if (r8.out.old_val->buf == NULL) { printf("OLD secret buffer not returned after OLD set\n"); - ret = False; + ret = false; } else if (r8.out.new_mtime == NULL || r8.out.old_mtime == NULL) { printf("Both times not returned after OLD set\n"); - ret = False; + ret = false; } else { if (i == LOCAL) { printf("NEW secret buffer should not be returned after LOCAL OLD set\n"); - ret = False; + ret = false; } blob1.data = r8.out.new_val->buf->data; blob1.length = r8.out.new_val->buf->length; @@ -1130,7 +1219,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, if (strcmp(secret3, secret4) != 0) { printf("Returned NEW secret '%s' doesn't match '%s'\n", secret4, secret3); - ret = False; + ret = false; } blob1.data = r8.out.old_val->buf->data; @@ -1143,7 +1232,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, if (strcmp(secret5, secret6) != 0) { printf("Returned OLD secret %s doesn't match %s\n", secret5, secret6); - ret = False; + ret = false; } if (*r8.out.new_mtime == *r8.out.old_mtime) { @@ -1151,27 +1240,27 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, printf("Returned secret %s had same mtime for both secrets: %s\n", secname[i], nt_time_string(mem_ctx, *r8.out.new_mtime)); - ret = False; + ret = false; } } else { printf("Returned secret %s should have had same mtime for both secrets: %s != %s\n", secname[i], nt_time_string(mem_ctx, *r8.out.old_mtime), nt_time_string(mem_ctx, *r8.out.new_mtime)); - ret = False; + ret = false; } } } if (!test_Delete(p, mem_ctx, &sec_handle)) { - ret = False; + ret = false; } d.in.handle = &sec_handle2; status = dcerpc_lsa_Delete(p, mem_ctx, &d); if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_HANDLE)) { printf("Second delete expected INVALID_HANDLE - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { printf("Testing OpenSecret of just-deleted secret\n"); @@ -1179,7 +1268,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenSecret(p, mem_ctx, &r2); if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { printf("OpenSecret expected OBJECT_NAME_NOT_FOUND - %s\n", nt_errstr(status)); - ret = False; + ret = false; } } @@ -1189,7 +1278,7 @@ static BOOL test_CreateSecret(struct dcerpc_pipe *p, } -static BOOL test_EnumAccountRights(struct dcerpc_pipe *p, +static bool test_EnumAccountRights(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *acct_handle, struct dom_sid *sid) @@ -1208,14 +1297,14 @@ static BOOL test_EnumAccountRights(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status)) { printf("EnumAccountRights of %s failed - %s\n", dom_sid_string(mem_ctx, sid), nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_QuerySecurity(struct dcerpc_pipe *p, +static bool test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct policy_handle *acct_handle) @@ -1223,9 +1312,9 @@ static BOOL test_QuerySecurity(struct dcerpc_pipe *p, NTSTATUS status; struct lsa_QuerySecurity r; - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping QuerySecurity test against Samba4\n"); - return True; + return true; } printf("Testing QuerySecurity\n"); @@ -1236,13 +1325,13 @@ static BOOL test_QuerySecurity(struct dcerpc_pipe *p, status = dcerpc_lsa_QuerySecurity(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("QuerySecurity failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_OpenAccount(struct dcerpc_pipe *p, +static bool test_OpenAccount(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct dom_sid *sid) @@ -1261,21 +1350,21 @@ static BOOL test_OpenAccount(struct dcerpc_pipe *p, status = dcerpc_lsa_OpenAccount(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("OpenAccount failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!test_EnumPrivsAccount(p, mem_ctx, handle, &acct_handle)) { - return False; + return false; } if (!test_QuerySecurity(p, mem_ctx, handle, &acct_handle)) { - return False; + return false; } - return True; + return true; } -static BOOL test_EnumAccounts(struct dcerpc_pipe *p, +static bool test_EnumAccounts(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -1284,7 +1373,7 @@ static BOOL test_EnumAccounts(struct dcerpc_pipe *p, struct lsa_SidArray sids1, sids2; uint32_t resume_handle = 0; int i; - BOOL ret = True; + bool ret = true; printf("\ntesting EnumAccounts\n"); @@ -1295,26 +1384,26 @@ static BOOL test_EnumAccounts(struct dcerpc_pipe *p, r.out.sids = &sids1; resume_handle = 0; - while (True) { + while (true) { status = dcerpc_lsa_EnumAccounts(p, mem_ctx, &r); if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) { break; } if (!NT_STATUS_IS_OK(status)) { printf("EnumAccounts failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!test_LookupSids(p, mem_ctx, handle, &sids1)) { - return False; + return false; } if (!test_LookupSids2(p, mem_ctx, handle, &sids1)) { - return False; + return false; } if (!test_LookupSids3(p, mem_ctx, &sids1)) { - return False; + return false; } printf("testing all accounts\n"); @@ -1337,18 +1426,18 @@ static BOOL test_EnumAccounts(struct dcerpc_pipe *p, status = dcerpc_lsa_EnumAccounts(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("EnumAccounts failed - %s\n", nt_errstr(status)); - return False; + return false; } if (sids2.num_sids != 1) { printf("Returned wrong number of entries (%d)\n", sids2.num_sids); - return False; + return false; } - return True; + return true; } -static BOOL test_LookupPrivDisplayName(struct dcerpc_pipe *p, +static bool test_LookupPrivDisplayName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *priv_name) @@ -1370,16 +1459,16 @@ static BOOL test_LookupPrivDisplayName(struct dcerpc_pipe *p, status = dcerpc_lsa_LookupPrivDisplayName(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("LookupPrivDisplayName failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("%s -> \"%s\" (language 0x%x/0x%x)\n", priv_name->string, r.out.disp_name->string, *r.in.language_id, *r.out.language_id); - return True; + return true; } -static BOOL test_EnumAccountsWithUserRight(struct dcerpc_pipe *p, +static bool test_EnumAccountsWithUserRight(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_String *priv_name) @@ -1400,19 +1489,19 @@ static BOOL test_EnumAccountsWithUserRight(struct dcerpc_pipe *p, /* NT_STATUS_NO_MORE_ENTRIES means noone has this privilege */ if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) { - return True; + return true; } if (!NT_STATUS_IS_OK(status)) { printf("EnumAccountsWithUserRight failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_EnumPrivs(struct dcerpc_pipe *p, +static bool test_EnumPrivs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -1421,7 +1510,7 @@ static BOOL test_EnumPrivs(struct dcerpc_pipe *p, struct lsa_PrivArray privs1; uint32_t resume_handle = 0; int i; - BOOL ret = True; + bool ret = true; printf("\ntesting EnumPrivs\n"); @@ -1435,26 +1524,26 @@ static BOOL test_EnumPrivs(struct dcerpc_pipe *p, status = dcerpc_lsa_EnumPrivs(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("EnumPrivs failed - %s\n", nt_errstr(status)); - return False; + return false; } for (i = 0; i< privs1.count; i++) { test_LookupPrivDisplayName(p, mem_ctx, handle, (struct lsa_String *)&privs1.privs[i].name); test_LookupPrivValue(p, mem_ctx, handle, (struct lsa_String *)&privs1.privs[i].name); if (!test_EnumAccountsWithUserRight(p, mem_ctx, handle, (struct lsa_String *)&privs1.privs[i].name)) { - ret = False; + ret = false; } } return ret; } -static BOOL test_QueryForestTrustInformation(struct dcerpc_pipe *p, +static bool test_QueryForestTrustInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char *trusted_domain_name) { - BOOL ret = True; + bool ret = true; struct lsa_lsaRQueryForestTrustInformation r; NTSTATUS status; struct lsa_String string; @@ -1462,9 +1551,9 @@ static BOOL test_QueryForestTrustInformation(struct dcerpc_pipe *p, printf("\nTesting lsaRQueryForestTrustInformation\n"); - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping QueryForestTrustInformation against Samba4\n"); - return True; + return true; } ZERO_STRUCT(string); @@ -1484,19 +1573,19 @@ static BOOL test_QueryForestTrustInformation(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status)) { printf("lsaRQueryForestTrustInformation failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_query_each_TrustDomEx(struct dcerpc_pipe *p, +static bool test_query_each_TrustDomEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_DomainListEx *domains) { int i; - BOOL ret = True; + bool ret = true; for (i=0; i< domains->count; i++) { @@ -1509,14 +1598,14 @@ static BOOL test_query_each_TrustDomEx(struct dcerpc_pipe *p, return ret; } -static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p, +static bool test_query_each_TrustDom(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct lsa_DomainList *domains) { NTSTATUS status; int i,j; - BOOL ret = True; + bool ret = true; printf("\nTesting OpenTrustedDomain, OpenTrustedDomainByName and QueryInfoTrustedDomain\n"); for (i=0; i< domains->count; i++) { @@ -1539,7 +1628,7 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status)) { printf("OpenTrustedDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } c.in.handle = &trustdom_handle; @@ -1558,18 +1647,18 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status) && ok[j]) { printf("QueryTrustedDomainInfo level %d failed - %s\n", levels[j], nt_errstr(status)); - ret = False; + ret = false; } else if (NT_STATUS_IS_OK(status) && !ok[j]) { printf("QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n", levels[j], nt_errstr(status)); - ret = False; + ret = false; } } status = dcerpc_lsa_CloseTrustedDomainEx(p, mem_ctx, &c_trust); if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) { printf("Expected CloseTrustedDomainEx to return NT_STATUS_NOT_IMPLEMENTED, instead - %s\n", nt_errstr(status)); - return False; + return false; } c.in.handle = &trustdom_handle; @@ -1578,7 +1667,7 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p, status = dcerpc_lsa_Close(p, mem_ctx, &c); if (!NT_STATUS_IS_OK(status)) { printf("Close of trusted domain failed - %s\n", nt_errstr(status)); - return False; + return false; } for (j=0; j < ARRAY_SIZE(levels); j++) { @@ -1597,11 +1686,11 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status) && ok[j]) { printf("QueryTrustedDomainInfoBySid level %d failed - %s\n", levels[j], nt_errstr(status)); - ret = False; + ret = false; } else if (NT_STATUS_IS_OK(status) && !ok[j]) { printf("QueryTrustedDomainInfoBySid level %d unexpectedly succeeded - %s\n", levels[j], nt_errstr(status)); - ret = False; + ret = false; } } } @@ -1615,7 +1704,7 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status)) { printf("OpenTrustedDomainByName failed - %s\n", nt_errstr(status)); - return False; + return false; } for (j=0; j < ARRAY_SIZE(levels); j++) { @@ -1628,11 +1717,11 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status) && ok[j]) { printf("QueryTrustedDomainInfo level %d failed - %s\n", levels[j], nt_errstr(status)); - ret = False; + ret = false; } else if (NT_STATUS_IS_OK(status) && !ok[j]) { printf("QueryTrustedDomainInfo level %d unexpectedly succeeded - %s\n", levels[j], nt_errstr(status)); - ret = False; + ret = false; } } @@ -1642,7 +1731,7 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p, status = dcerpc_lsa_Close(p, mem_ctx, &c); if (!NT_STATUS_IS_OK(status)) { printf("Close of trusted domain failed - %s\n", nt_errstr(status)); - return False; + return false; } for (j=0; j < ARRAY_SIZE(levels); j++) { @@ -1656,18 +1745,18 @@ static BOOL test_query_each_TrustDom(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status) && ok[j]) { printf("QueryTrustedDomainInfoByName level %d failed - %s\n", levels[j], nt_errstr(status)); - ret = False; + ret = false; } else if (NT_STATUS_IS_OK(status) && !ok[j]) { printf("QueryTrustedDomainInfoByName level %d unexpectedly succeeded - %s\n", levels[j], nt_errstr(status)); - ret = False; + ret = false; } } } return ret; } -static BOOL test_EnumTrustDom(struct dcerpc_pipe *p, +static bool test_EnumTrustDom(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -1677,7 +1766,7 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p, uint32_t resume_handle = 0; struct lsa_DomainList domains; struct lsa_DomainListEx domains_ex; - BOOL ret = True; + bool ret = true; printf("\nTesting EnumTrustDom\n"); @@ -1692,7 +1781,7 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p, /* NO_MORE_ENTRIES is allowed */ if (NT_STATUS_EQUAL(enum_status, NT_STATUS_NO_MORE_ENTRIES)) { - return True; + return true; } else if (NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES)) { /* Windows 2003 gets this off by one on the first run */ if (r.out.domains->count < 3 || r.out.domains->count > 4) { @@ -1700,11 +1789,11 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p, "asked it to (got %d, expected %d / %d == %d entries)\n", r.out.domains->count, LSA_ENUM_TRUST_DOMAIN_MULTIPLIER * 3, LSA_ENUM_TRUST_DOMAIN_MULTIPLIER, r.in.max_size); - ret = False; + ret = false; } } else if (!NT_STATUS_IS_OK(enum_status)) { printf("EnumTrustDom failed - %s\n", nt_errstr(enum_status)); - return False; + return false; } ret &= test_query_each_TrustDom(p, mem_ctx, handle, &domains); @@ -1725,7 +1814,7 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p, /* NO_MORE_ENTRIES is allowed */ if (NT_STATUS_EQUAL(enum_status, NT_STATUS_NO_MORE_ENTRIES)) { - return True; + return true; } else if (NT_STATUS_EQUAL(enum_status, STATUS_MORE_ENTRIES)) { /* Windows 2003 gets this off by one on the first run */ if (r_ex.out.domains->count < 3 || r_ex.out.domains->count > 4) { @@ -1735,12 +1824,12 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p, r_ex.in.max_size, LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER, r_ex.in.max_size / LSA_ENUM_TRUST_DOMAIN_EX_MULTIPLIER); - ret = False; + ret = false; exit(1); } } else if (!NT_STATUS_IS_OK(enum_status)) { printf("EnumTrustedDomainEx failed - %s\n", nt_errstr(enum_status)); - return False; + return false; } ret &= test_query_each_TrustDomEx(p, mem_ctx, handle, &domains_ex); @@ -1750,12 +1839,12 @@ static BOOL test_EnumTrustDom(struct dcerpc_pipe *p, return ret; } -static BOOL test_CreateTrustedDomain(struct dcerpc_pipe *p, +static bool test_CreateTrustedDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct lsa_CreateTrustedDomain r; struct lsa_DomainInfo trustinfo; struct dom_sid *domsid[12]; @@ -1786,7 +1875,7 @@ static BOOL test_CreateTrustedDomain(struct dcerpc_pipe *p, } if (!NT_STATUS_IS_OK(status)) { printf("CreateTrustedDomain failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { q.in.trustdom_handle = &trustdom_handle[i]; @@ -1794,14 +1883,14 @@ static BOOL test_CreateTrustedDomain(struct dcerpc_pipe *p, status = dcerpc_lsa_QueryTrustedDomainInfo(p, mem_ctx, &q); if (!NT_STATUS_IS_OK(status)) { printf("QueryTrustedDomainInfo level 1 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else if (!q.out.info) { - ret = False; + ret = false; } else { if (strcmp(q.out.info->name.netbios_name.string, trustinfo.name.string) != 0) { printf("QueryTrustedDomainInfo returned inconsistant short name: %s != %s\n", q.out.info->name.netbios_name.string, trustinfo.name.string); - ret = False; + ret = false; } } } @@ -1809,29 +1898,29 @@ static BOOL test_CreateTrustedDomain(struct dcerpc_pipe *p, /* now that we have some domains to look over, we can test the enum calls */ if (!test_EnumTrustDom(p, mem_ctx, handle)) { - ret = False; + ret = false; } for (i=0; i<12; i++) { if (!test_DeleteTrustedDomainBySid(p, mem_ctx, handle, domsid[i])) { - ret = False; + ret = false; } } return ret; } -static BOOL test_QueryDomainInfoPolicy(struct dcerpc_pipe *p, +static bool test_QueryDomainInfoPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { struct lsa_QueryDomainInformationPolicy r; NTSTATUS status; int i; - BOOL ret = True; - if (lp_parm_bool(-1, "torture", "samba4", False)) { + bool ret = true; + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping QueryDomainInformationPolicy test against Samba4\n"); - return True; + return true; } printf("\nTesting QueryDomainInformationPolicy\n"); @@ -1846,7 +1935,7 @@ static BOOL test_QueryDomainInfoPolicy(struct dcerpc_pipe *p, if (!NT_STATUS_IS_OK(status)) { printf("QueryDomainInformationPolicy failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; continue; } } @@ -1855,19 +1944,19 @@ static BOOL test_QueryDomainInfoPolicy(struct dcerpc_pipe *p, } -static BOOL test_QueryInfoPolicy(struct dcerpc_pipe *p, +static bool test_QueryInfoPolicy(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { struct lsa_QueryInfoPolicy r; NTSTATUS status; int i; - BOOL ret = True; + bool ret = true; printf("\nTesting QueryInfoPolicy\n"); - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping QueryInfoPolicy against Samba4\n"); - return True; + return true; } for (i=1;i<13;i++) { @@ -1878,36 +1967,69 @@ static BOOL test_QueryInfoPolicy(struct dcerpc_pipe *p, status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r); - if ((i == 9 || i == 10 || i == 11) && - NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { - printf("server failed level %u (OK)\n", i); - continue; + switch (i) { + case LSA_POLICY_INFO_DB: + case LSA_POLICY_INFO_AUDIT_FULL_SET: + case LSA_POLICY_INFO_AUDIT_FULL_QUERY: + if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { + printf("server should have failed level %u: %s\n", i, nt_errstr(status)); + ret = false; + } + break; + case LSA_POLICY_INFO_DOMAIN: + case LSA_POLICY_INFO_ACCOUNT_DOMAIN: + case LSA_POLICY_INFO_DNS: + if (!NT_STATUS_IS_OK(status)) { + printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); + ret = false; + } + break; + default: + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { + /* Other levels not implemented yet */ + if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) { + printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); + ret = false; + } + } else if (!NT_STATUS_IS_OK(status)) { + printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); + ret = false; + } + break; } - if (!NT_STATUS_IS_OK(status)) { - printf("QueryInfoPolicy failed - %s\n", nt_errstr(status)); - ret = False; - continue; + if (NT_STATUS_IS_OK(status) && i == LSA_POLICY_INFO_DNS) { + /* Let's look up some of these names */ + + struct lsa_TransNameArray tnames; + tnames.count = 10; + tnames.names = talloc_array(mem_ctx, struct lsa_TranslatedName, tnames.count); + tnames.names[0].name.string = r.out.info->dns.name.string; + tnames.names[1].name.string = r.out.info->dns.dns_domain.string; + tnames.names[2].name.string = talloc_asprintf(mem_ctx, "%s\\", r.out.info->dns.name.string); + tnames.names[3].name.string = talloc_asprintf(mem_ctx, "%s\\", r.out.info->dns.dns_domain.string); + tnames.names[4].name.string = talloc_asprintf(mem_ctx, "%s\\guest", r.out.info->dns.name.string); + tnames.names[5].name.string = talloc_asprintf(mem_ctx, "%s\\krbtgt", r.out.info->dns.name.string); + tnames.names[6].name.string = talloc_asprintf(mem_ctx, "%s\\guest", r.out.info->dns.dns_domain.string); + tnames.names[7].name.string = talloc_asprintf(mem_ctx, "%s\\krbtgt", r.out.info->dns.dns_domain.string); + tnames.names[8].name.string = talloc_asprintf(mem_ctx, "krbtgt@%s", r.out.info->dns.name.string); + tnames.names[9].name.string = talloc_asprintf(mem_ctx, "krbtgt@%s", r.out.info->dns.dns_domain.string); + ret &= test_LookupNames(p, mem_ctx, handle, &tnames); } } return ret; } -static BOOL test_QueryInfoPolicy2(struct dcerpc_pipe *p, +static bool test_QueryInfoPolicy2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { struct lsa_QueryInfoPolicy2 r; NTSTATUS status; int i; - BOOL ret = True; + bool ret = true; printf("\nTesting QueryInfoPolicy2\n"); - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping QueryInfoPolicy2 against Samba4\n"); - return True; - } - for (i=1;i<13;i++) { r.in.handle = handle; r.in.level = i; @@ -1915,28 +2037,47 @@ static BOOL test_QueryInfoPolicy2(struct dcerpc_pipe *p, printf("\ntrying QueryInfoPolicy2 level %d\n", i); status = dcerpc_lsa_QueryInfoPolicy2(p, mem_ctx, &r); - - if ((i == 9 || i == 10 || i == 11) && - NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { - printf("server failed level %u (OK)\n", i); - continue; - } - - if (!NT_STATUS_IS_OK(status)) { - printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); - ret = False; - continue; + + switch (i) { + case LSA_POLICY_INFO_DB: + case LSA_POLICY_INFO_AUDIT_FULL_SET: + case LSA_POLICY_INFO_AUDIT_FULL_QUERY: + if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { + printf("server should have failed level %u: %s\n", i, nt_errstr(status)); + ret = false; + } + break; + case LSA_POLICY_INFO_DOMAIN: + case LSA_POLICY_INFO_ACCOUNT_DOMAIN: + case LSA_POLICY_INFO_DNS: + if (!NT_STATUS_IS_OK(status)) { + printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); + ret = false; + } + break; + default: + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { + /* Other levels not implemented yet */ + if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_INFO_CLASS)) { + printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); + ret = false; + } + } else if (!NT_STATUS_IS_OK(status)) { + printf("QueryInfoPolicy2 failed - %s\n", nt_errstr(status)); + ret = false; + } + break; } } return ret; } -static BOOL test_GetUserName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_GetUserName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { struct lsa_GetUserName r; NTSTATUS status; - BOOL ret = True; + bool ret = true; struct lsa_StringPointer authority_name_p; printf("\nTesting GetUserName\n"); @@ -1950,13 +2091,13 @@ static BOOL test_GetUserName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) if (!NT_STATUS_IS_OK(status)) { printf("GetUserName failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -BOOL test_lsa_Close(struct dcerpc_pipe *p, +bool test_lsa_Close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { @@ -1972,27 +2113,27 @@ BOOL test_lsa_Close(struct dcerpc_pipe *p, status = dcerpc_lsa_Close(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Close failed - %s\n", nt_errstr(status)); - return False; + return false; } status = dcerpc_lsa_Close(p, mem_ctx, &r); /* its really a fault - we need a status code for rpc fault */ if (!NT_STATUS_EQUAL(status, NT_STATUS_NET_WRITE_FAULT)) { printf("Close failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("\n"); - return True; + return true; } -BOOL torture_rpc_lsa(struct torture_context *torture) +bool torture_rpc_lsa(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct policy_handle *handle; mem_ctx = talloc_init("torture_rpc_lsa"); @@ -2000,75 +2141,83 @@ BOOL torture_rpc_lsa(struct torture_context *torture) status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); - return False; + return false; } if (!test_OpenPolicy(p, mem_ctx)) { - ret = False; + ret = false; } if (!test_lsa_OpenPolicy2(p, mem_ctx, &handle)) { - ret = False; + ret = false; } if (handle) { + if (!test_LookupNames_wellknown(p, mem_ctx, handle)) { + ret = false; + } + + if (!test_LookupNames_bogus(p, mem_ctx, handle)) { + ret = false; + } + if (!test_LookupSids_async(p, mem_ctx, handle)) { - ret = False; + ret = false; } if (!test_QueryDomainInfoPolicy(p, mem_ctx, handle)) { - ret = False; + ret = false; } if (!test_CreateAccount(p, mem_ctx, handle)) { - ret = False; + ret = false; } if (!test_CreateSecret(p, mem_ctx, handle)) { - ret = False; + ret = false; } if (!test_CreateTrustedDomain(p, mem_ctx, handle)) { - ret = False; + ret = false; } if (!test_EnumAccounts(p, mem_ctx, handle)) { - ret = False; + ret = false; } if (!test_EnumPrivs(p, mem_ctx, handle)) { - ret = False; + ret = false; } if (!test_QueryInfoPolicy(p, mem_ctx, handle)) { - ret = False; + ret = false; } if (!test_QueryInfoPolicy2(p, mem_ctx, handle)) { - ret = False; + ret = false; } #if 0 if (!test_Delete(p, mem_ctx, handle)) { - ret = False; + ret = false; } #endif if (!test_many_LookupSids(p, mem_ctx, handle)) { - ret = False; + ret = false; } if (!test_lsa_Close(p, mem_ctx, handle)) { - ret = False; + ret = false; } } else { if (!test_many_LookupSids(p, mem_ctx, handle)) { - ret = False; + ret = false; } } if (!test_GetUserName(p, mem_ctx)) { - ret = False; + ret = false; } talloc_free(mem_ctx); @@ -2076,23 +2225,23 @@ BOOL torture_rpc_lsa(struct torture_context *torture) return ret; } -BOOL torture_rpc_lsa_get_user(struct torture_context *torture) +bool torture_rpc_lsa_get_user(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; mem_ctx = talloc_init("torture_rpc_lsa_get_user"); status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); - return False; + return false; } if (!test_GetUserName(p, mem_ctx)) { - ret = False; + ret = false; } talloc_free(mem_ctx); diff --git a/source4/torture/rpc/lsa_lookup.c b/source4/torture/rpc/lsa_lookup.c index d90c3694a9..9c817a7061 100644 --- a/source4/torture/rpc/lsa_lookup.c +++ b/source4/torture/rpc/lsa_lookup.c @@ -26,7 +26,7 @@ #include "librpc/gen_ndr/ndr_lsa_c.h" #include "libcli/security/security.h" -static BOOL open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, +static bool open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, struct policy_handle **handle) { struct lsa_ObjectAttribute attr; @@ -36,7 +36,7 @@ static BOOL open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, *handle = talloc(mem_ctx, struct policy_handle); if (!*handle) { - return False; + return false; } qos.len = 0; @@ -61,7 +61,7 @@ static BOOL open_policy(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, return NT_STATUS_IS_OK(status); } -static BOOL get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, +static bool get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, struct policy_handle *handle, struct dom_sid **sid) { @@ -72,10 +72,10 @@ static BOOL get_domainsid(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, r.in.handle = handle; status = dcerpc_lsa_QueryInfoPolicy(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) return False; + if (!NT_STATUS_IS_OK(status)) return false; *sid = r.out.info->domain.sid; - return True; + return true; } static NTSTATUS lookup_sids(TALLOC_CTX *mem_ctx, uint16_t level, @@ -122,11 +122,12 @@ static const char *sid_type_lookup(enum lsa_SidType r) case SID_NAME_DELETED: return "SID_NAME_DELETED"; break; case SID_NAME_INVALID: return "SID_NAME_INVALID"; break; case SID_NAME_UNKNOWN: return "SID_NAME_UNKNOWN"; break; + case SID_NAME_COMPUTER: return "SID_NAME_COMPUTER"; break; } return "Invalid sid type\n"; } -static BOOL test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, +static bool test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, struct policy_handle *handle, struct dom_sid **sids, uint32_t num_sids, int level, NTSTATUS expected_result, @@ -135,7 +136,7 @@ static BOOL test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, struct lsa_TransNameArray names; NTSTATUS status; uint32_t i; - BOOL ret = True; + bool ret = true; status = lookup_sids(mem_ctx, level, p, handle, sids, num_sids, &names); @@ -143,12 +144,12 @@ static BOOL test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, printf("For level %d expected %s, got %s\n", level, nt_errstr(expected_result), nt_errstr(status)); - return False; + return false; } if (!NT_STATUS_EQUAL(status, NT_STATUS_OK) && !NT_STATUS_EQUAL(status, STATUS_SOME_UNMAPPED)) { - return True; + return true; } for (i=0; i<num_sids; i++) { @@ -158,13 +159,13 @@ static BOOL test_lookupsids(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, dom_sid_string(mem_ctx, sids[i]), sid_type_lookup(types[i]), sid_type_lookup(names.names[i].sid_type)); - ret = False; + ret = false; } } return ret; } -static BOOL get_downleveltrust(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, +static bool get_downleveltrust(struct torture_context *tctx, struct dcerpc_pipe *p, struct policy_handle *handle, struct dom_sid **sid) { @@ -180,16 +181,13 @@ static BOOL get_downleveltrust(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, r.out.domains = &domains; r.out.resume_handle = &resume_handle; - status = dcerpc_lsa_EnumTrustDom(p, mem_ctx, &r); + status = dcerpc_lsa_EnumTrustDom(p, tctx, &r); - if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) { - printf("no trusts\n"); - return False; - } + if (NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)) + torture_fail(tctx, "no trusts"); if (domains.count == 0) { - printf("no trusts\n"); - return False; + torture_fail(tctx, "no trusts"); } for (i=0; i<domains.count; i++) { @@ -201,62 +199,58 @@ static BOOL get_downleveltrust(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *p, q.in.handle = handle; q.in.dom_sid = domains.domains[i].sid; q.in.level = 6; - status = dcerpc_lsa_QueryTrustedDomainInfoBySid(p, mem_ctx, &q); + status = dcerpc_lsa_QueryTrustedDomainInfoBySid(p, tctx, &q); if (!NT_STATUS_IS_OK(status)) continue; if ((q.out.info->info_ex.trust_direction & 2) && (q.out.info->info_ex.trust_type == 1)) { *sid = domains.domains[i].sid; - return True; + return true; } } - printf("I need a AD DC with an outgoing trust to NT4\n"); - return False; + torture_fail(tctx, "I need a AD DC with an outgoing trust to NT4"); } #define NUM_SIDS 8 -BOOL torture_rpc_lsa_lookup(struct torture_context *torture) +bool torture_rpc_lsa_lookup(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct policy_handle *handle; struct dom_sid *dom_sid; struct dom_sid *trusted_sid; struct dom_sid *sids[NUM_SIDS]; - mem_ctx = talloc_init("torture_rpc_lsa"); - status = torture_rpc_connection(torture, &p, &ndr_table_lsarpc); if (!NT_STATUS_IS_OK(status)) { - ret = False; - goto done; + torture_fail(torture, "unable to connect to table"); } - ret &= open_policy(mem_ctx, p, &handle); - if (!ret) goto done; + ret &= open_policy(torture, p, &handle); + if (!ret) return false; - ret &= get_domainsid(mem_ctx, p, handle, &dom_sid); - if (!ret) goto done; + ret &= get_domainsid(torture, p, handle, &dom_sid); + if (!ret) return false; - ret &= get_downleveltrust(mem_ctx, p, handle, &trusted_sid); - if (!ret) goto done; + ret &= get_downleveltrust(torture, p, handle, &trusted_sid); + if (!ret) return false; - printf("domain sid: %s\n", dom_sid_string(mem_ctx, dom_sid)); + torture_comment(torture, "domain sid: %s\n", + dom_sid_string(torture, dom_sid)); - sids[0] = dom_sid_parse_talloc(mem_ctx, "S-1-1-0"); - sids[1] = dom_sid_parse_talloc(mem_ctx, "S-1-5-4"); - sids[2] = dom_sid_parse_talloc(mem_ctx, "S-1-5-32"); - sids[3] = dom_sid_parse_talloc(mem_ctx, "S-1-5-32-545"); - sids[4] = dom_sid_dup(mem_ctx, dom_sid); - sids[5] = dom_sid_add_rid(mem_ctx, dom_sid, 512); - sids[6] = dom_sid_dup(mem_ctx, trusted_sid); - sids[7] = dom_sid_add_rid(mem_ctx, trusted_sid, 512); + sids[0] = dom_sid_parse_talloc(torture, "S-1-1-0"); + sids[1] = dom_sid_parse_talloc(torture, "S-1-5-4"); + sids[2] = dom_sid_parse_talloc(torture, "S-1-5-32"); + sids[3] = dom_sid_parse_talloc(torture, "S-1-5-32-545"); + sids[4] = dom_sid_dup(torture, dom_sid); + sids[5] = dom_sid_add_rid(torture, dom_sid, 512); + sids[6] = dom_sid_dup(torture, trusted_sid); + sids[7] = dom_sid_add_rid(torture, trusted_sid, 512); - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 0, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 0, NT_STATUS_INVALID_PARAMETER, NULL); { @@ -265,7 +259,7 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture) SID_NAME_ALIAS, SID_NAME_DOMAIN, SID_NAME_DOM_GRP, SID_NAME_DOMAIN, SID_NAME_DOM_GRP }; - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 1, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 1, NT_STATUS_OK, types); } @@ -275,7 +269,7 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture) SID_NAME_UNKNOWN, SID_NAME_UNKNOWN, SID_NAME_DOMAIN, SID_NAME_DOM_GRP, SID_NAME_DOMAIN, SID_NAME_DOM_GRP }; - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 2, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 2, STATUS_SOME_UNMAPPED, types); } @@ -285,7 +279,7 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture) SID_NAME_UNKNOWN, SID_NAME_UNKNOWN, SID_NAME_DOMAIN, SID_NAME_DOM_GRP, SID_NAME_UNKNOWN, SID_NAME_UNKNOWN }; - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 3, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 3, STATUS_SOME_UNMAPPED, types); } @@ -295,11 +289,11 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture) SID_NAME_UNKNOWN, SID_NAME_UNKNOWN, SID_NAME_DOMAIN, SID_NAME_DOM_GRP, SID_NAME_UNKNOWN, SID_NAME_UNKNOWN }; - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 4, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 4, STATUS_SOME_UNMAPPED, types); } - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 5, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 5, NT_STATUS_NONE_MAPPED, NULL); { @@ -308,21 +302,18 @@ BOOL torture_rpc_lsa_lookup(struct torture_context *torture) SID_NAME_UNKNOWN, SID_NAME_UNKNOWN, SID_NAME_DOMAIN, SID_NAME_DOM_GRP, SID_NAME_UNKNOWN, SID_NAME_UNKNOWN }; - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 6, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 6, STATUS_SOME_UNMAPPED, types); } - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 7, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 7, NT_STATUS_INVALID_PARAMETER, NULL); - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 8, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 8, NT_STATUS_INVALID_PARAMETER, NULL); - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 9, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 9, NT_STATUS_INVALID_PARAMETER, NULL); - ret &= test_lookupsids(mem_ctx, p, handle, sids, NUM_SIDS, 10, + ret &= test_lookupsids(torture, p, handle, sids, NUM_SIDS, 10, NT_STATUS_INVALID_PARAMETER, NULL); - done: - talloc_free(mem_ctx); - return ret; } diff --git a/source4/torture/rpc/mgmt.c b/source4/torture/rpc/mgmt.c index 6d0c3d56c9..258450ada1 100644 --- a/source4/torture/rpc/mgmt.c +++ b/source4/torture/rpc/mgmt.c @@ -24,14 +24,15 @@ #include "auth/gensec/gensec.h" #include "librpc/ndr/ndr_table.h" #include "torture/rpc/rpc.h" +#include "param/param.h" /* ask the server what interface IDs are available on this endpoint */ -BOOL test_inq_if_ids(struct torture_context *tctx, +bool test_inq_if_ids(struct torture_context *tctx, struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - BOOL (*per_id_test)(struct torture_context *, + bool (*per_id_test)(struct torture_context *, const struct ndr_interface_table *iface, TALLOC_CTX *mem_ctx, struct ndr_syntax_id *id), @@ -48,17 +49,17 @@ BOOL test_inq_if_ids(struct torture_context *tctx, status = dcerpc_mgmt_inq_if_ids(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("inq_if_ids failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!W_ERROR_IS_OK(r.out.result)) { printf("inq_if_ids gave error code %s\n", win_errstr(r.out.result)); - return False; + return false; } if (!vector) { printf("inq_if_ids gave NULL if_id_vector\n"); - return False; + return false; } for (i=0;i<vector->count;i++) { @@ -75,10 +76,10 @@ BOOL test_inq_if_ids(struct torture_context *tctx, } } - return True; + return true; } -static BOOL test_inq_stats(struct dcerpc_pipe *p, +static bool test_inq_stats(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { NTSTATUS status; @@ -92,12 +93,12 @@ static BOOL test_inq_stats(struct dcerpc_pipe *p, status = dcerpc_mgmt_inq_stats(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("inq_stats failed - %s\n", nt_errstr(status)); - return False; + return false; } if (statistics.count != MGMT_STATS_ARRAY_MAX_SIZE) { printf("Unexpected array size %d\n", statistics.count); - return False; + return false; } printf("\tcalls_in %6d calls_out %6d\n\tpkts_in %6d pkts_out %6d\n", @@ -106,16 +107,16 @@ static BOOL test_inq_stats(struct dcerpc_pipe *p, statistics.statistics[MGMT_STATS_PKTS_IN], statistics.statistics[MGMT_STATS_PKTS_OUT]); - return True; + return true; } -static BOOL test_inq_princ_name(struct dcerpc_pipe *p, +static bool test_inq_princ_name(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { NTSTATUS status; struct mgmt_inq_princ_name r; int i; - BOOL ret = False; + bool ret = false; for (i=0;i<100;i++) { r.in.authn_proto = i; /* DCERPC_AUTH_TYPE_* */ @@ -127,7 +128,7 @@ static BOOL test_inq_princ_name(struct dcerpc_pipe *p, } if (W_ERROR_IS_OK(r.out.result)) { const char *name = gensec_get_name_by_authtype(i); - ret = True; + ret = true; if (name) { printf("\tprinciple name for proto %u (%s) is '%s'\n", i, name, r.out.princ_name); @@ -142,10 +143,10 @@ static BOOL test_inq_princ_name(struct dcerpc_pipe *p, printf("\tno principle names?\n"); } - return True; + return true; } -static BOOL test_is_server_listening(struct dcerpc_pipe *p, +static bool test_is_server_listening(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { NTSTATUS status; @@ -155,7 +156,7 @@ static BOOL test_is_server_listening(struct dcerpc_pipe *p, status = dcerpc_mgmt_is_server_listening(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("is_server_listening failed - %s\n", nt_errstr(status)); - return False; + return false; } if (*r.out.status != 0 || r.out.result == 0) { @@ -164,10 +165,10 @@ static BOOL test_is_server_listening(struct dcerpc_pipe *p, printf("\tserver is listening\n"); } - return True; + return true; } -static BOOL test_stop_server_listening(struct dcerpc_pipe *p, +static bool test_stop_server_listening(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) { NTSTATUS status; @@ -176,26 +177,26 @@ static BOOL test_stop_server_listening(struct dcerpc_pipe *p, status = dcerpc_mgmt_stop_server_listening(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("stop_server_listening failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!W_ERROR_IS_OK(r.out.result)) { printf("\tserver refused to stop listening - %s\n", win_errstr(r.out.result)); } else { printf("\tserver allowed a stop_server_listening request\n"); - return False; + return false; } - return True; + return true; } -BOOL torture_rpc_mgmt(struct torture_context *torture) +bool torture_rpc_mgmt(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx, *loop_ctx; - BOOL ret = True; + bool ret = true; const struct ndr_interface_list *l; struct dcerpc_binding *b; @@ -204,7 +205,7 @@ BOOL torture_rpc_mgmt(struct torture_context *torture) status = torture_rpc_binding(torture, &b); if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); - return False; + return false; } for (l=ndr_table_list();l;l=l->next) { @@ -227,7 +228,7 @@ BOOL torture_rpc_mgmt(struct torture_context *torture) continue; } - lp_set_cmdline("torture:binding", dcerpc_binding_string(loop_ctx, b)); + lp_set_cmdline(global_loadparm, "torture:binding", dcerpc_binding_string(loop_ctx, b)); status = torture_rpc_connection(torture, &p, &ndr_table_mgmt); if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { @@ -238,28 +239,28 @@ BOOL torture_rpc_mgmt(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { talloc_free(loop_ctx); - ret = False; + ret = false; continue; } if (!test_is_server_listening(p, loop_ctx)) { - ret = False; + ret = false; } if (!test_stop_server_listening(p, loop_ctx)) { - ret = False; + ret = false; } if (!test_inq_stats(p, loop_ctx)) { - ret = False; + ret = false; } if (!test_inq_princ_name(p, loop_ctx)) { - ret = False; + ret = false; } if (!test_inq_if_ids(torture, p, loop_ctx, NULL, NULL)) { - ret = False; + ret = false; } } diff --git a/source4/torture/rpc/netlogon.c b/source4/torture/rpc/netlogon.c index df69a097b6..3ff0561f77 100644 --- a/source4/torture/rpc/netlogon.c +++ b/source4/torture/rpc/netlogon.c @@ -30,66 +30,44 @@ #include "libcli/auth/libcli_auth.h" #include "librpc/gen_ndr/ndr_netlogon_c.h" #include "librpc/gen_ndr/ndr_lsa_c.h" - -static const char *machine_password; +#include "param/param.h" #define TEST_MACHINE_NAME "torturetest" -static BOOL test_LogonUasLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_LogonUasLogon(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_LogonUasLogon r; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping LogonUasLogon test against Samba4\n"); - return True; - } - r.in.server_name = NULL; r.in.account_name = cli_credentials_get_username(cmdline_credentials); r.in.workstation = TEST_MACHINE_NAME; - printf("Testing LogonUasLogon\n"); - - status = dcerpc_netr_LogonUasLogon(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonUasLogon - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_LogonUasLogon(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonUasLogon"); - return True; - + return true; } -static BOOL test_LogonUasLogoff(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_LogonUasLogoff(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_LogonUasLogoff r; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping LogonUasLogoff test against Samba4\n"); - return True; - } - r.in.server_name = NULL; r.in.account_name = cli_credentials_get_username(cmdline_credentials); r.in.workstation = TEST_MACHINE_NAME; - printf("Testing LogonUasLogoff\n"); + status = dcerpc_netr_LogonUasLogoff(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonUasLogoff"); - status = dcerpc_netr_LogonUasLogoff(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonUasLogoff - %s\n", nt_errstr(status)); - return False; - } - - return True; - + return true; } -static BOOL test_SetupCredentials(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - const char *machine_name, - const char *plain_pass, +static bool test_SetupCredentials(struct dcerpc_pipe *p, struct torture_context *tctx, + struct cli_credentials *credentials, struct creds_CredentialState **creds_out) { NTSTATUS status; @@ -98,13 +76,16 @@ static BOOL test_SetupCredentials(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct netr_Credential credentials1, credentials2, credentials3; struct creds_CredentialState *creds; struct samr_Password mach_password; + const char *plain_pass; + const char *machine_name; - printf("Testing ServerReqChallenge\n"); + plain_pass = cli_credentials_get_password(credentials); + machine_name = cli_credentials_get_workstation(credentials); - creds = talloc(mem_ctx, struct creds_CredentialState); - if (!creds) { - return False; - } + torture_comment(tctx, "Testing ServerReqChallenge\n"); + + creds = talloc(tctx, struct creds_CredentialState); + torture_assert(tctx, creds != NULL, "memory allocation"); r.in.server_name = NULL; r.in.computer_name = machine_name; @@ -113,16 +94,13 @@ static BOOL test_SetupCredentials(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, generate_random_buffer(credentials1.data, sizeof(credentials1.data)); - status = dcerpc_netr_ServerReqChallenge(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerReqChallenge - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerReqChallenge(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerReqChallenge"); E_md4hash(plain_pass, mach_password.hash); a.in.server_name = NULL; - a.in.account_name = talloc_asprintf(mem_ctx, "%s$", machine_name); + a.in.account_name = talloc_asprintf(tctx, "%s$", machine_name); a.in.secure_channel_type = SEC_CHAN_BDC; a.in.computer_name = machine_name; a.in.credentials = &credentials3; @@ -132,27 +110,21 @@ static BOOL test_SetupCredentials(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, &mach_password, &credentials3, 0); - printf("Testing ServerAuthenticate\n"); + torture_comment(tctx, "Testing ServerAuthenticate\n"); - status = dcerpc_netr_ServerAuthenticate(p, mem_ctx, &a); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerAuthenticate - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerAuthenticate(p, tctx, &a); + torture_assert_ntstatus_ok(tctx, status, "ServerAuthenticate"); - if (!creds_client_check(creds, &credentials3)) { - printf("Credential chaining failed\n"); - return False; - } + torture_assert(tctx, creds_client_check(creds, &credentials3), + "Credential chaining failed"); *creds_out = creds; - return True; + return true; } -static BOOL test_SetupCredentials2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetupCredentials2(struct dcerpc_pipe *p, struct torture_context *tctx, uint32_t negotiate_flags, - const char *machine_name, - const char *plain_pass, + struct cli_credentials *machine_credentials, int sec_chan_type, struct creds_CredentialState **creds_out) { @@ -162,13 +134,16 @@ static BOOL test_SetupCredentials2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct netr_Credential credentials1, credentials2, credentials3; struct creds_CredentialState *creds; struct samr_Password mach_password; + const char *machine_name; + const char *plain_pass; - printf("Testing ServerReqChallenge\n"); + machine_name = cli_credentials_get_workstation(machine_credentials); + plain_pass = cli_credentials_get_password(machine_credentials); - creds = talloc(mem_ctx, struct creds_CredentialState); - if (!creds) { - return False; - } + torture_comment(tctx, "Testing ServerReqChallenge\n"); + + creds = talloc(tctx, struct creds_CredentialState); + torture_assert(tctx, creds != NULL, "memory allocation"); r.in.server_name = NULL; r.in.computer_name = machine_name; @@ -177,16 +152,13 @@ static BOOL test_SetupCredentials2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, generate_random_buffer(credentials1.data, sizeof(credentials1.data)); - status = dcerpc_netr_ServerReqChallenge(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerReqChallenge - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerReqChallenge(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerReqChallenge"); E_md4hash(plain_pass, mach_password.hash); a.in.server_name = NULL; - a.in.account_name = talloc_asprintf(mem_ctx, "%s$", machine_name); + a.in.account_name = talloc_asprintf(tctx, "%s$", machine_name); a.in.secure_channel_type = sec_chan_type; a.in.computer_name = machine_name; a.in.negotiate_flags = &negotiate_flags; @@ -198,30 +170,24 @@ static BOOL test_SetupCredentials2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, &mach_password, &credentials3, negotiate_flags); - printf("Testing ServerAuthenticate2\n"); + torture_comment(tctx, "Testing ServerAuthenticate2\n"); - status = dcerpc_netr_ServerAuthenticate2(p, mem_ctx, &a); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerAuthenticate2 - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerAuthenticate2(p, tctx, &a); + torture_assert_ntstatus_ok(tctx, status, "ServerAuthenticate2"); - if (!creds_client_check(creds, &credentials3)) { - printf("Credential chaining failed\n"); - return False; - } + torture_assert(tctx, creds_client_check(creds, &credentials3), + "Credential chaining failed"); - printf("negotiate_flags=0x%08x\n", negotiate_flags); + torture_comment(tctx, "negotiate_flags=0x%08x\n", negotiate_flags); *creds_out = creds; - return True; + return true; } -static BOOL test_SetupCredentials3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetupCredentials3(struct dcerpc_pipe *p, struct torture_context *tctx, uint32_t negotiate_flags, - const char *machine_name, - const char *plain_pass, + struct cli_credentials *machine_credentials, struct creds_CredentialState **creds_out) { NTSTATUS status; @@ -231,13 +197,16 @@ static BOOL test_SetupCredentials3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct creds_CredentialState *creds; struct samr_Password mach_password; uint32_t rid; + const char *machine_name; + const char *plain_pass; - printf("Testing ServerReqChallenge\n"); + machine_name = cli_credentials_get_workstation(machine_credentials); + plain_pass = cli_credentials_get_password(machine_credentials); - creds = talloc(mem_ctx, struct creds_CredentialState); - if (!creds) { - return False; - } + torture_comment(tctx, "Testing ServerReqChallenge\n"); + + creds = talloc(tctx, struct creds_CredentialState); + torture_assert(tctx, creds != NULL, "memory allocation"); r.in.server_name = NULL; r.in.computer_name = machine_name; @@ -246,16 +215,13 @@ static BOOL test_SetupCredentials3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, generate_random_buffer(credentials1.data, sizeof(credentials1.data)); - status = dcerpc_netr_ServerReqChallenge(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerReqChallenge - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerReqChallenge(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerReqChallenge"); E_md4hash(plain_pass, mach_password.hash); a.in.server_name = NULL; - a.in.account_name = talloc_asprintf(mem_ctx, "%s$", machine_name); + a.in.account_name = talloc_asprintf(tctx, "%s$", machine_name); a.in.secure_channel_type = SEC_CHAN_BDC; a.in.computer_name = machine_name; a.in.negotiate_flags = &negotiate_flags; @@ -268,98 +234,90 @@ static BOOL test_SetupCredentials3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, &mach_password, &credentials3, negotiate_flags); - printf("Testing ServerAuthenticate3\n"); + torture_comment(tctx, "Testing ServerAuthenticate3\n"); - status = dcerpc_netr_ServerAuthenticate3(p, mem_ctx, &a); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerAuthenticate3 - %s\n", nt_errstr(status)); - return False; - } - - if (!creds_client_check(creds, &credentials3)) { - printf("Credential chaining failed\n"); - return False; - } + status = dcerpc_netr_ServerAuthenticate3(p, tctx, &a); + torture_assert_ntstatus_ok(tctx, status, "ServerAuthenticate3"); + torture_assert(tctx, creds_client_check(creds, &credentials3), "Credential chaining failed"); - printf("negotiate_flags=0x%08x\n", negotiate_flags); + torture_comment(tctx, "negotiate_flags=0x%08x\n", negotiate_flags); *creds_out = creds; - return True; + return true; } /* try a change password for our machine account */ -static BOOL test_SetPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_SetPassword(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *machine_credentials) { NTSTATUS status; struct netr_ServerPasswordSet r; const char *password; struct creds_CredentialState *creds; - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, - machine_password, &creds)) { - return False; + if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) { + return false; } - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.account_name = talloc_asprintf(mem_ctx, "%s$", TEST_MACHINE_NAME); + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + r.in.account_name = talloc_asprintf(tctx, "%s$", TEST_MACHINE_NAME); r.in.secure_channel_type = SEC_CHAN_BDC; r.in.computer_name = TEST_MACHINE_NAME; - password = generate_random_str(mem_ctx, 8); + password = generate_random_str(tctx, 8); E_md4hash(password, r.in.new_password.hash); creds_des_encrypt(creds, &r.in.new_password); - printf("Testing ServerPasswordSet on machine account\n"); - d_printf("Changing machine account password to '%s'\n", password); + torture_comment(tctx, "Testing ServerPasswordSet on machine account\n"); + torture_comment(tctx, "Changing machine account password to '%s'\n", + password); creds_client_authenticator(creds, &r.in.credential); - status = dcerpc_netr_ServerPasswordSet(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerPasswordSet - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerPasswordSet(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet"); if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { - printf("Credential chaining failed\n"); + torture_comment(tctx, "Credential chaining failed\n"); } /* by changing the machine password twice we test the credentials chaining fully, and we verify that the server allows the password to be set to the same value twice in a row (match win2k3) */ - printf("Testing a second ServerPasswordSet on machine account\n"); - d_printf("Changing machine account password to '%s' (same as previous run)\n", password); + torture_comment(tctx, + "Testing a second ServerPasswordSet on machine account\n"); + torture_comment(tctx, + "Changing machine account password to '%s' (same as previous run)\n", password); creds_client_authenticator(creds, &r.in.credential); - status = dcerpc_netr_ServerPasswordSet(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerPasswordSet (2) - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerPasswordSet(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet (2)"); if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { - printf("Credential chaining failed\n"); + torture_comment(tctx, "Credential chaining failed\n"); } - machine_password = password; + cli_credentials_set_password(machine_credentials, password, CRED_SPECIFIED); - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) { - printf("ServerPasswordSet failed to actually change the password\n"); - return False; - } + torture_assert(tctx, + test_SetupCredentials(p, tctx, machine_credentials, &creds), + "ServerPasswordSet failed to actually change the password"); - return True; + return true; } /* try a change password for our machine account */ -static BOOL test_SetPassword2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_SetPassword2(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *machine_credentials) { NTSTATUS status; struct netr_ServerPasswordSet2 r; @@ -367,42 +325,39 @@ static BOOL test_SetPassword2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) struct creds_CredentialState *creds; struct samr_CryptPassword password_buf; - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, - machine_password, &creds)) { - return False; + if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) { + return false; } - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.account_name = talloc_asprintf(mem_ctx, "%s$", TEST_MACHINE_NAME); + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + r.in.account_name = talloc_asprintf(tctx, "%s$", TEST_MACHINE_NAME); r.in.secure_channel_type = SEC_CHAN_BDC; r.in.computer_name = TEST_MACHINE_NAME; - password = generate_random_str(mem_ctx, 8); + password = generate_random_str(tctx, 8); encode_pw_buffer(password_buf.data, password, STR_UNICODE); creds_arcfour_crypt(creds, password_buf.data, 516); memcpy(r.in.new_password.data, password_buf.data, 512); r.in.new_password.length = IVAL(password_buf.data, 512); - printf("Testing ServerPasswordSet2 on machine account\n"); - d_printf("Changing machine account password to '%s'\n", password); + torture_comment(tctx, "Testing ServerPasswordSet2 on machine account\n"); + torture_comment(tctx, "Changing machine account password to '%s'\n", password); creds_client_authenticator(creds, &r.in.credential); - status = dcerpc_netr_ServerPasswordSet2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerPasswordSet2 - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerPasswordSet2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet2"); if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { - printf("Credential chaining failed\n"); + torture_comment(tctx, "Credential chaining failed\n"); } - machine_password = password; + cli_credentials_set_password(machine_credentials, password, CRED_SPECIFIED); - if (!lp_parm_bool(-1, "torture", "dangerous", False)) { - printf("Not testing ability to set password to '', enable dangerous tests to perform this test\n"); + if (!torture_setting_bool(tctx, "dangerous", false)) { + torture_comment(tctx, + "Not testing ability to set password to '', enable dangerous tests to perform this test\n"); } else { /* by changing the machine password to "" * we check if the server uses password restrictions @@ -416,85 +371,77 @@ static BOOL test_SetPassword2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) memcpy(r.in.new_password.data, password_buf.data, 512); r.in.new_password.length = IVAL(password_buf.data, 512); - printf("Testing ServerPasswordSet2 on machine account\n"); - d_printf("Changing machine account password to '%s'\n", password); + torture_comment(tctx, + "Testing ServerPasswordSet2 on machine account\n"); + torture_comment(tctx, + "Changing machine account password to '%s'\n", password); creds_client_authenticator(creds, &r.in.credential); - status = dcerpc_netr_ServerPasswordSet2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerPasswordSet2 - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerPasswordSet2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet2"); if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { - printf("Credential chaining failed\n"); + torture_comment(tctx, "Credential chaining failed\n"); } - machine_password = password; + cli_credentials_set_password(machine_credentials, password, CRED_SPECIFIED); } - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) { - printf("ServerPasswordSet failed to actually change the password\n"); - return False; - } + torture_assert(tctx, test_SetupCredentials(p, tctx, machine_credentials, &creds), + "ServerPasswordSet failed to actually change the password"); /* now try a random password */ - password = generate_random_str(mem_ctx, 8); + password = generate_random_str(tctx, 8); encode_pw_buffer(password_buf.data, password, STR_UNICODE); creds_arcfour_crypt(creds, password_buf.data, 516); memcpy(r.in.new_password.data, password_buf.data, 512); r.in.new_password.length = IVAL(password_buf.data, 512); - printf("Testing second ServerPasswordSet2 on machine account\n"); - d_printf("Changing machine account password to '%s'\n", password); + torture_comment(tctx, "Testing second ServerPasswordSet2 on machine account\n"); + torture_comment(tctx, "Changing machine account password to '%s'\n", password); creds_client_authenticator(creds, &r.in.credential); - status = dcerpc_netr_ServerPasswordSet2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerPasswordSet2 (2) - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerPasswordSet2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet2 (2)"); if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { - printf("Credential chaining failed\n"); + torture_comment(tctx, "Credential chaining failed\n"); } /* by changing the machine password twice we test the credentials chaining fully, and we verify that the server allows the password to be set to the same value twice in a row (match win2k3) */ - printf("Testing a second ServerPasswordSet2 on machine account\n"); - d_printf("Changing machine account password to '%s' (same as previous run)\n", password); + torture_comment(tctx, + "Testing a second ServerPasswordSet2 on machine account\n"); + torture_comment(tctx, + "Changing machine account password to '%s' (same as previous run)\n", password); creds_client_authenticator(creds, &r.in.credential); - status = dcerpc_netr_ServerPasswordSet2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ServerPasswordSet (3) - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_ServerPasswordSet2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ServerPasswordSet (3)"); if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { - printf("Credential chaining failed\n"); + torture_comment(tctx, "Credential chaining failed\n"); } - machine_password = password; + cli_credentials_set_password(machine_credentials, password, CRED_SPECIFIED); - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) { - printf("ServerPasswordSet failed to actually change the password\n"); - return False; - } + torture_assert (tctx, + test_SetupCredentials(p, tctx, machine_credentials, &creds), + "ServerPasswordSet failed to actually change the password"); - return True; + return true; } /* try a netlogon SamLogon */ -BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_netlogon_ops(struct dcerpc_pipe *p, struct torture_context *tctx, struct cli_credentials *credentials, struct creds_CredentialState *creds) { @@ -504,17 +451,16 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct netr_NetworkInfo ninfo; DATA_BLOB names_blob, chal, lm_resp, nt_resp; int i; - BOOL ret = True; int flags = CLI_CRED_NTLM_AUTH; - if (lp_client_lanman_auth()) { + if (lp_client_lanman_auth(global_loadparm)) { flags |= CLI_CRED_LANMAN_AUTH; } - if (lp_client_ntlmv2_auth()) { + if (lp_client_ntlmv2_auth(global_loadparm)) { flags |= CLI_CRED_NTLMv2_AUTH; } - cli_credentials_get_ntlm_username_domain(cmdline_credentials, mem_ctx, + cli_credentials_get_ntlm_username_domain(cmdline_credentials, tctx, &ninfo.identity_info.account_name.string, &ninfo.identity_info.domain_name.string); @@ -523,20 +469,16 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, chal = data_blob_const(ninfo.challenge, sizeof(ninfo.challenge)); - names_blob = NTLMv2_generate_names_blob(mem_ctx, cli_credentials_get_workstation(credentials), + names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials), cli_credentials_get_domain(credentials)); - status = cli_credentials_get_ntlm_response(cmdline_credentials, mem_ctx, + status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx, &flags, chal, names_blob, &lm_resp, &nt_resp, NULL, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("cli_credentials_get_ntlm_response failed: %s\n", - nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "cli_credentials_get_ntlm_response failed"); ninfo.lm.data = lm_resp.data; ninfo.lm.length = lm_resp.length; @@ -549,7 +491,7 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ninfo.identity_info.logon_id_high = 0; ninfo.identity_info.workstation.string = cli_credentials_get_workstation(credentials); - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.computer_name = cli_credentials_get_workstation(credentials); r.in.credential = &auth; r.in.return_authenticator = &auth2; @@ -564,17 +506,11 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.validation_level = i; - status = dcerpc_netr_LogonSamLogon(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonSamLogon failed: %s\n", - nt_errstr(status)); - return False; - } + status = dcerpc_netr_LogonSamLogon(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonSamLogon failed"); - if (!creds_client_check(creds, &r.out.return_authenticator->cred)) { - printf("Credential chaining failed\n"); - ret = False; - } + torture_assert(tctx, creds_client_check(creds, &r.out.return_authenticator->cred), + "Credential chaining failed"); } r.in.credential = NULL; @@ -583,33 +519,31 @@ BOOL test_netlogon_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.validation_level = i; - printf("Testing SamLogon with validation level %d and a NULL credential\n", i); + torture_comment(tctx, "Testing SamLogon with validation level %d and a NULL credential\n", i); - status = dcerpc_netr_LogonSamLogon(p, mem_ctx, &r); - if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { - printf("LogonSamLogon expected INVALID_PARAMETER, got: %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonSamLogon(p, tctx, &r); + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_INVALID_PARAMETER, + "LogonSamLogon expected INVALID_PARAMETER"); } - return ret; + return true; } /* try a netlogon SamLogon */ -static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SamLogon(struct torture_context *tctx, + struct dcerpc_pipe *p, struct cli_credentials *credentials) { struct creds_CredentialState *creds; - if (!test_SetupCredentials(p, mem_ctx, cli_credentials_get_workstation(credentials), - cli_credentials_get_password(credentials), &creds)) { - return False; + if (!test_SetupCredentials(p, tctx, credentials, &creds)) { + return false; } - return test_netlogon_ops(p, mem_ctx, credentials, creds); + return test_netlogon_ops(p, tctx, credentials, creds); } /* we remember the sequence numbers so we can easily do a DatabaseDelta */ @@ -618,25 +552,21 @@ static uint64_t sequence_nums[3]; /* try a netlogon DatabaseSync */ -static BOOL test_DatabaseSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_DatabaseSync(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *machine_credentials) { NTSTATUS status; struct netr_DatabaseSync r; struct creds_CredentialState *creds; const uint32_t database_ids[] = {SAM_DATABASE_DOMAIN, SAM_DATABASE_BUILTIN, SAM_DATABASE_PRIVS}; int i; - BOOL ret = True; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DatabaseSync test against Samba4\n"); - return True; + if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) { + return false; } - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) { - return False; - } - - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.computername = TEST_MACHINE_NAME; r.in.preferredmaximumlength = (uint32_t)-1; ZERO_STRUCT(r.in.return_authenticator); @@ -645,21 +575,19 @@ static BOOL test_DatabaseSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.in.sync_context = 0; r.in.database_id = database_ids[i]; - printf("Testing DatabaseSync of id %d\n", r.in.database_id); + torture_comment(tctx, "Testing DatabaseSync of id %d\n", r.in.database_id); do { creds_client_authenticator(creds, &r.in.credential); - status = dcerpc_netr_DatabaseSync(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && - !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { - printf("DatabaseSync - %s\n", nt_errstr(status)); - ret = False; - break; - } + status = dcerpc_netr_DatabaseSync(p, tctx, &r); + if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) + break; + + torture_assert_ntstatus_ok(tctx, status, "DatabaseSync"); if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { - printf("Credential chaining failed\n"); + torture_comment(tctx, "Credential chaining failed\n"); } r.in.sync_context = r.out.sync_context; @@ -670,39 +598,35 @@ static BOOL test_DatabaseSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.out.delta_enum_array->delta_enum[0].delta_union.domain) { sequence_nums[r.in.database_id] = r.out.delta_enum_array->delta_enum[0].delta_union.domain->sequence_num; - printf("\tsequence_nums[%d]=%llu\n", + torture_comment(tctx, "\tsequence_nums[%d]=%llu\n", r.in.database_id, (unsigned long long)sequence_nums[r.in.database_id]); } } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)); } - return ret; + return true; } /* try a netlogon DatabaseDeltas */ -static BOOL test_DatabaseDeltas(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_DatabaseDeltas(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *machine_credentials) { NTSTATUS status; struct netr_DatabaseDeltas r; struct creds_CredentialState *creds; const uint32_t database_ids[] = {0, 1, 2}; int i; - BOOL ret = True; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DatabaseDeltas test against Samba4\n"); - return True; + if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) { + return false; } - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) { - return False; - } - - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.computername = TEST_MACHINE_NAME; r.in.preferredmaximumlength = (uint32_t)-1; ZERO_STRUCT(r.in.return_authenticator); @@ -715,54 +639,52 @@ static BOOL test_DatabaseDeltas(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.in.sequence_num -= 1; - - printf("Testing DatabaseDeltas of id %d at %llu\n", + torture_comment(tctx, "Testing DatabaseDeltas of id %d at %llu\n", r.in.database_id, (unsigned long long)r.in.sequence_num); do { creds_client_authenticator(creds, &r.in.credential); - status = dcerpc_netr_DatabaseDeltas(p, mem_ctx, &r); + status = dcerpc_netr_DatabaseDeltas(p, tctx, &r); if (NT_STATUS_EQUAL(status, NT_STATUS_SYNCHRONIZATION_REQUIRED)) { - printf("no considering %s to be an error\n", + torture_comment(tctx, "not considering %s to be an error\n", nt_errstr(status)); - return True; - } - if (!NT_STATUS_IS_OK(status) && - !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { - printf("DatabaseDeltas - %s\n", nt_errstr(status)); - ret = False; - break; + return true; } + if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) + break; + + torture_assert_ntstatus_ok(tctx, status, "DatabaseDeltas"); if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { - printf("Credential chaining failed\n"); + torture_comment(tctx, "Credential chaining failed\n"); } r.in.sequence_num++; } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)); } - return ret; + return true; } /* try a netlogon AccountDeltas */ -static BOOL test_AccountDeltas(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_AccountDeltas(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *machine_credentials) { NTSTATUS status; struct netr_AccountDeltas r; struct creds_CredentialState *creds; - BOOL ret = True; - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) { - return False; + if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) { + return false; } - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.computername = TEST_MACHINE_NAME; ZERO_STRUCT(r.in.return_authenticator); creds_client_authenticator(creds, &r.in.credential); @@ -771,33 +693,28 @@ static BOOL test_AccountDeltas(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.in.level=0; r.in.buffersize=100; - printf("Testing AccountDeltas\n"); - /* w2k3 returns "NOT IMPLEMENTED" for this call */ - status = dcerpc_netr_AccountDeltas(p, mem_ctx, &r); - if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) { - printf("AccountDeltas - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_AccountDeltas(p, tctx, &r); + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_NOT_IMPLEMENTED, "AccountDeltas"); - return ret; + return true; } /* try a netlogon AccountSync */ -static BOOL test_AccountSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_AccountSync(struct torture_context *tctx, struct dcerpc_pipe *p, + struct cli_credentials *machine_credentials) { NTSTATUS status; struct netr_AccountSync r; struct creds_CredentialState *creds; - BOOL ret = True; - if (!test_SetupCredentials(p, mem_ctx, TEST_MACHINE_NAME, machine_password, &creds)) { - return False; + if (!test_SetupCredentials(p, tctx, machine_credentials, &creds)) { + return false; } - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.computername = TEST_MACHINE_NAME; ZERO_STRUCT(r.in.return_authenticator); creds_client_authenticator(creds, &r.in.credential); @@ -806,177 +723,132 @@ static BOOL test_AccountSync(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.in.level=0; r.in.buffersize=100; - printf("Testing AccountSync\n"); - /* w2k3 returns "NOT IMPLEMENTED" for this call */ - status = dcerpc_netr_AccountSync(p, mem_ctx, &r); - if (!NT_STATUS_EQUAL(status, NT_STATUS_NOT_IMPLEMENTED)) { - printf("AccountSync - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_AccountSync(p, tctx, &r); + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_NOT_IMPLEMENTED, "AccountSync"); - return ret; + return true; } /* try a netlogon GetDcName */ -static BOOL test_GetDcName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_GetDcName(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_GetDcName r; + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + r.in.domainname = lp_workgroup(global_loadparm); - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping GetDCName test against Samba4\n"); - return True; - } - - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.domainname = lp_workgroup(); - - printf("Testing GetDcName\n"); - - status = dcerpc_netr_GetDcName(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - printf("GetDcName - %s/%s\n", nt_errstr(status), win_errstr(r.out.result)); - return False; - } + status = dcerpc_netr_GetDcName(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetDcName"); + torture_assert_werr_ok(tctx, r.out.result, "GetDcName"); - d_printf("\tDC is at '%s'\n", r.out.dcname); + torture_comment(tctx, "\tDC is at '%s'\n", r.out.dcname); - return True; + return true; } /* try a netlogon LogonControl */ -static BOOL test_LogonControl(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_LogonControl(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_LogonControl r; - BOOL ret = True; int i; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping LogonControl test against Samba4\n"); - return True; - } - - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.function_code = 1; for (i=1;i<4;i++) { r.in.level = i; - printf("Testing LogonControl level %d\n", i); + torture_comment(tctx, "Testing LogonControl level %d\n", i); - status = dcerpc_netr_LogonControl(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonControl - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonControl(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonControl"); } - return ret; + return true; } /* try a netlogon GetAnyDCName */ -static BOOL test_GetAnyDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_GetAnyDCName(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_GetAnyDCName r; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping GetAnyDCName test against Samba4\n"); - return True; - } - - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.domainname = lp_workgroup(); + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + r.in.domainname = lp_workgroup(global_loadparm); - printf("Testing GetAnyDCName\n"); - - status = dcerpc_netr_GetAnyDCName(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetAnyDCName - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_netr_GetAnyDCName(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetAnyDCName"); if (r.out.dcname) { - printf("\tDC is at '%s'\n", r.out.dcname); + torture_comment(tctx, "\tDC is at '%s'\n", r.out.dcname); } - return True; + return true; } /* try a netlogon LogonControl2 */ -static BOOL test_LogonControl2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_LogonControl2(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_LogonControl2 r; - BOOL ret = True; int i; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping LogonControl2 test against Samba4\n"); - return True; - } - - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.function_code = NETLOGON_CONTROL_REDISCOVER; - r.in.data.domain = lp_workgroup(); + r.in.data.domain = lp_workgroup(global_loadparm); for (i=1;i<4;i++) { r.in.level = i; - printf("Testing LogonControl2 level %d function %d\n", + torture_comment(tctx, "Testing LogonControl2 level %d function %d\n", i, r.in.function_code); - status = dcerpc_netr_LogonControl2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonControl - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonControl2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonControl"); } r.in.function_code = NETLOGON_CONTROL_TC_QUERY; - r.in.data.domain = lp_workgroup(); + r.in.data.domain = lp_workgroup(global_loadparm); for (i=1;i<4;i++) { r.in.level = i; - printf("Testing LogonControl2 level %d function %d\n", + torture_comment(tctx, "Testing LogonControl2 level %d function %d\n", i, r.in.function_code); - status = dcerpc_netr_LogonControl2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonControl - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonControl2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonControl"); } r.in.function_code = NETLOGON_CONTROL_TRANSPORT_NOTIFY; - r.in.data.domain = lp_workgroup(); + r.in.data.domain = lp_workgroup(global_loadparm); for (i=1;i<4;i++) { r.in.level = i; - printf("Testing LogonControl2 level %d function %d\n", + torture_comment(tctx, "Testing LogonControl2 level %d function %d\n", i, r.in.function_code); - status = dcerpc_netr_LogonControl2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonControl - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonControl2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonControl"); } r.in.function_code = NETLOGON_CONTROL_SET_DBFLAG; @@ -985,43 +857,36 @@ static BOOL test_LogonControl2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) for (i=1;i<4;i++) { r.in.level = i; - printf("Testing LogonControl2 level %d function %d\n", + torture_comment(tctx, "Testing LogonControl2 level %d function %d\n", i, r.in.function_code); - status = dcerpc_netr_LogonControl2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonControl - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonControl2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonControl"); } - return ret; + return true; } /* try a netlogon DatabaseSync2 */ -static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_DatabaseSync2(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *machine_credentials) { NTSTATUS status; struct netr_DatabaseSync2 r; struct creds_CredentialState *creds; const uint32_t database_ids[] = {0, 1, 2}; int i; - BOOL ret = True; - if (!test_SetupCredentials2(p, mem_ctx, NETLOGON_NEG_AUTH2_FLAGS, - TEST_MACHINE_NAME, machine_password, + if (!test_SetupCredentials2(p, tctx, NETLOGON_NEG_AUTH2_FLAGS, + machine_credentials, SEC_CHAN_BDC, &creds)) { - return False; - } - - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DatabaseSync2 test against Samba4\n"); - return True; + return false; } - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.computername = TEST_MACHINE_NAME; r.in.preferredmaximumlength = (uint32_t)-1; ZERO_STRUCT(r.in.return_authenticator); @@ -1031,94 +896,78 @@ static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.in.database_id = database_ids[i]; r.in.restart_state = 0; - printf("Testing DatabaseSync2 of id %d\n", r.in.database_id); + torture_comment(tctx, "Testing DatabaseSync2 of id %d\n", r.in.database_id); do { creds_client_authenticator(creds, &r.in.credential); - status = dcerpc_netr_DatabaseSync2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) && - !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { - printf("DatabaseSync2 - %s\n", nt_errstr(status)); - ret = False; - break; - } + status = dcerpc_netr_DatabaseSync2(p, tctx, &r); + if (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) + break; + + torture_assert_ntstatus_ok(tctx, status, "DatabaseSync2"); if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { - printf("Credential chaining failed\n"); + torture_comment(tctx, "Credential chaining failed\n"); } r.in.sync_context = r.out.sync_context; } while (NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)); } - return ret; + return true; } /* try a netlogon LogonControl2Ex */ -static BOOL test_LogonControl2Ex(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_LogonControl2Ex(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_LogonControl2Ex r; - BOOL ret = True; int i; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DatabaseSync2 test against Samba4\n"); - return True; - } - - r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.function_code = NETLOGON_CONTROL_REDISCOVER; - r.in.data.domain = lp_workgroup(); + r.in.data.domain = lp_workgroup(global_loadparm); for (i=1;i<4;i++) { r.in.level = i; - printf("Testing LogonControl2Ex level %d function %d\n", + torture_comment(tctx, "Testing LogonControl2Ex level %d function %d\n", i, r.in.function_code); - status = dcerpc_netr_LogonControl2Ex(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonControl - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonControl2Ex(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonControl"); } r.in.function_code = NETLOGON_CONTROL_TC_QUERY; - r.in.data.domain = lp_workgroup(); + r.in.data.domain = lp_workgroup(global_loadparm); for (i=1;i<4;i++) { r.in.level = i; - printf("Testing LogonControl2Ex level %d function %d\n", + torture_comment(tctx, "Testing LogonControl2Ex level %d function %d\n", i, r.in.function_code); - status = dcerpc_netr_LogonControl2Ex(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonControl - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonControl2Ex(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonControl"); } r.in.function_code = NETLOGON_CONTROL_TRANSPORT_NOTIFY; - r.in.data.domain = lp_workgroup(); + r.in.data.domain = lp_workgroup(global_loadparm); for (i=1;i<4;i++) { r.in.level = i; - printf("Testing LogonControl2Ex level %d function %d\n", + torture_comment(tctx, "Testing LogonControl2Ex level %d function %d\n", i, r.in.function_code); - status = dcerpc_netr_LogonControl2Ex(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonControl - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonControl2Ex(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonControl"); } r.in.function_code = NETLOGON_CONTROL_SET_DBFLAG; @@ -1127,77 +976,63 @@ static BOOL test_LogonControl2Ex(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) for (i=1;i<4;i++) { r.in.level = i; - printf("Testing LogonControl2Ex level %d function %d\n", + torture_comment(tctx, "Testing LogonControl2Ex level %d function %d\n", i, r.in.function_code); - status = dcerpc_netr_LogonControl2Ex(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonControl - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_netr_LogonControl2Ex(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonControl"); } - return ret; + return true; } -static BOOL test_netr_DsRGetForestTrustInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *trusted_domain_name) +static bool test_netr_DsRGetForestTrustInformation(struct torture_context *tctx, + struct dcerpc_pipe *p, const char *trusted_domain_name) { NTSTATUS status; struct netr_DsRGetForestTrustInformation r; - BOOL ret = True; struct lsa_ForestTrustInformation info, *info_ptr; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsRGetForestTrustInformation test against Samba4\n"); - return True; - } - info_ptr = &info; - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.trusted_domain_name = trusted_domain_name; r.in.flags = 0; r.out.forest_trust_info = &info_ptr; - printf("Testing netr_DsRGetForestTrustInformation\n"); + torture_comment(tctx ,"Testing netr_DsRGetForestTrustInformation\n"); - status = dcerpc_netr_DsRGetForestTrustInformation(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - printf("netr_DsRGetForestTrustInformation - %s/%s\n", - nt_errstr(status), win_errstr(r.out.result)); - ret = False; - } - return ret; + status = dcerpc_netr_DsRGetForestTrustInformation(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "DsRGetForestTrustInformation"); + torture_assert_werr_ok(tctx, r.out.result, "DsRGetForestTrustInformation"); + + return true; } /* try a netlogon netr_DsrEnumerateDomainTrusts */ -static BOOL test_DsrEnumerateDomainTrusts(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_DsrEnumerateDomainTrusts(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_DsrEnumerateDomainTrusts r; int i; - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.trust_flags = 0x3f; - printf("Testing netr_DsrEnumerateDomainTrusts\n"); - - status = dcerpc_netr_DsrEnumerateDomainTrusts(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - printf("netr_DsrEnumerateDomainTrusts - %s/%s\n", - nt_errstr(status), win_errstr(r.out.result)); - return False; - } + status = dcerpc_netr_DsrEnumerateDomainTrusts(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "DsrEnumerateDomaintrusts"); + torture_assert_werr_ok(tctx, r.out.result, "DsrEnumerateDomaintrusts"); /* when trusted_domain_name is NULL, netr_DsRGetForestTrustInformation * will show non-forest trusts and all UPN suffixes of the own forest * as LSA_FOREST_TRUST_TOP_LEVEL_NAME types */ if (r.out.count) { - if (!test_netr_DsRGetForestTrustInformation(p, mem_ctx, NULL)) { - return False; + if (!test_netr_DsRGetForestTrustInformation(tctx, p, NULL)) { + return false; } } @@ -1206,194 +1041,145 @@ static BOOL test_DsrEnumerateDomainTrusts(struct dcerpc_pipe *p, TALLOC_CTX *mem /* get info for transitive forest trusts */ if (r.out.trusts[i].trust_attributes & NETR_TRUST_ATTRIBUTE_FOREST_TRANSITIVE) { - if (!test_netr_DsRGetForestTrustInformation(p, mem_ctx, + if (!test_netr_DsRGetForestTrustInformation(tctx, p, r.out.trusts[i].dns_name)) { - return False; + return false; } } } - return True; + return true; } -static BOOL test_netr_DsRGetSiteName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_netr_DsRGetSiteName(struct dcerpc_pipe *p, struct torture_context *tctx, const char *computer_name, const char *expected_site) { NTSTATUS status; struct netr_DsRGetSiteName r; - BOOL ret = True; - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsRGetSiteName test against Samba4\n"); - return True; - } + if (torture_setting_bool(tctx, "samba4", false)) + torture_skip(tctx, "skipping DsRGetSiteName test against Samba4"); r.in.computer_name = computer_name; - printf("Testing netr_DsRGetSiteName\n"); + torture_comment(tctx, "Testing netr_DsRGetSiteName\n"); - status = dcerpc_netr_DsRGetSiteName(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - printf("netr_DsRGetSiteName - %s/%s\n", - nt_errstr(status), win_errstr(r.out.result)); - ret = False; - } else { - if (strcmp(expected_site, r.out.site) != 0) { - d_printf("netr_DsRGetSiteName - unexpected result: %s, expected %s\n", - r.out.site, expected_site); - - ret = False; - } - } - r.in.computer_name = talloc_asprintf(mem_ctx, "\\\\%s", computer_name); - d_printf("Testing netr_DsRGetSiteName with broken computer name: %s\n", r.in.computer_name); - - status = dcerpc_netr_DsRGetSiteName(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("netr_DsRGetSiteName - %s\n", - nt_errstr(status)); - ret = False; - } else if (!W_ERROR_EQUAL(r.out.result, WERR_INVALID_COMPUTERNAME)) { - printf("netr_DsRGetSiteName - incorrect error return %s, expected %s\n", - win_errstr(r.out.result), win_errstr(WERR_INVALID_COMPUTERNAME)); - ret = False; - } - return ret; + status = dcerpc_netr_DsRGetSiteName(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "DsRGetSiteName"); + torture_assert_werr_ok(tctx, r.out.result, "DsRGetSiteName"); + torture_assert_str_equal(tctx, expected_site, r.out.site, "netr_DsRGetSiteName"); + + r.in.computer_name = talloc_asprintf(tctx, "\\\\%s", computer_name); + torture_comment(tctx, + "Testing netr_DsRGetSiteName with broken computer name: %s\n", r.in.computer_name); + + status = dcerpc_netr_DsRGetSiteName(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "DsRGetSiteName"); + torture_assert_werr_equal(tctx, r.out.result, WERR_INVALID_COMPUTERNAME, "netr_DsRGetSiteName"); + + return true; } /* try a netlogon netr_DsRGetDCName */ -static BOOL test_netr_DsRGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_netr_DsRGetDCName(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_DsRGetDCName r; - BOOL ret = True; - r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.domain_name = talloc_asprintf(mem_ctx, "%s", lp_realm()); + r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(global_loadparm)); r.in.domain_guid = NULL; r.in.site_guid = NULL; r.in.flags = DS_RETURN_DNS_NAME; - printf("Testing netr_DsRGetDCName\n"); - - status = dcerpc_netr_DsRGetDCName(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - printf("netr_DsRGetDCName - %s/%s\n", - nt_errstr(status), win_errstr(r.out.result)); - ret = False; - } else { - ret = test_netr_DsRGetSiteName(p, mem_ctx, - r.out.info->dc_unc, - r.out.info->dc_site_name); - } - - return ret; + status = dcerpc_netr_DsRGetDCName(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "DsRGetDCName"); + torture_assert_werr_ok(tctx, r.out.result, "DsRGetDCName"); + return test_netr_DsRGetSiteName(p, tctx, + r.out.info->dc_unc, + r.out.info->dc_site_name); } /* try a netlogon netr_DsRGetDCNameEx */ -static BOOL test_netr_DsRGetDCNameEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_netr_DsRGetDCNameEx(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_DsRGetDCNameEx r; - BOOL ret = True; - r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); - r.in.domain_name = talloc_asprintf(mem_ctx, "%s", lp_realm()); + r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(global_loadparm)); r.in.domain_guid = NULL; r.in.site_name = NULL; r.in.flags = DS_RETURN_DNS_NAME; - printf("Testing netr_DsRGetDCNameEx\n"); - - status = dcerpc_netr_DsRGetDCNameEx(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - printf("netr_DsRGetDCNameEx - %s/%s\n", - nt_errstr(status), win_errstr(r.out.result)); - ret = False; - } else { - ret = test_netr_DsRGetSiteName(p, mem_ctx, - r.out.info->dc_unc, - r.out.info->dc_site_name); - } + status = dcerpc_netr_DsRGetDCNameEx(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "netr_DsRGetDCNameEx"); + torture_assert_werr_ok(tctx, r.out.result, "netr_DsRGetDCNameEx"); - return ret; + return test_netr_DsRGetSiteName(p, tctx, r.out.info->dc_unc, + r.out.info->dc_site_name); } /* try a netlogon netr_DsRGetDCNameEx2 */ -static BOOL test_netr_DsRGetDCNameEx2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_netr_DsRGetDCNameEx2(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_DsRGetDCNameEx2 r; - BOOL ret = True; - r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.client_account = NULL; r.in.mask = 0x00000000; - r.in.domain_name = talloc_asprintf(mem_ctx, "%s", lp_realm()); + r.in.domain_name = talloc_asprintf(tctx, "%s", lp_realm(global_loadparm)); r.in.domain_guid = NULL; r.in.site_name = NULL; r.in.flags = DS_RETURN_DNS_NAME; - printf("Testing netr_DsRGetDCNameEx2 without client account\n"); + torture_comment(tctx, "Testing netr_DsRGetDCNameEx2 without client account\n"); - status = dcerpc_netr_DsRGetDCNameEx2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - printf("netr_DsRGetDCNameEx2 - %s/%s\n", - nt_errstr(status), win_errstr(r.out.result)); - ret = False; - } + status = dcerpc_netr_DsRGetDCNameEx2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "netr_DsRGetDCNameEx2"); + torture_assert_werr_ok(tctx, r.out.result, "netr_DsRGetDCNameEx2"); - printf("Testing netr_DsRGetDCNameEx2 with client acount\n"); + torture_comment(tctx, "Testing netr_DsRGetDCNameEx2 with client acount\n"); r.in.client_account = TEST_MACHINE_NAME"$"; r.in.mask = ACB_SVRTRUST; r.in.flags = DS_RETURN_FLAT_NAME; - status = dcerpc_netr_DsRGetDCNameEx2(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - printf("netr_DsRGetDCNameEx2 - %s/%s\n", - nt_errstr(status), win_errstr(r.out.result)); - ret = False; - } else { - ret = test_netr_DsRGetSiteName(p, mem_ctx, - r.out.info->dc_unc, - r.out.info->dc_site_name); - } - - return ret; + status = dcerpc_netr_DsRGetDCNameEx2(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "netr_DsRGetDCNameEx2"); + torture_assert_werr_ok(tctx, r.out.result, "netr_DsRGetDCNameEx2"); + return test_netr_DsRGetSiteName(p, tctx, r.out.info->dc_unc, + r.out.info->dc_site_name); } -static BOOL test_netr_DsrGetDcSiteCoverageW(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_netr_DsrGetDcSiteCoverageW(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct netr_DsrGetDcSiteCoverageW r; - BOOL ret = True; - - if (lp_parm_bool(-1, "torture", "samba4", False)) { - printf("skipping DsrGetDcSiteCoverageW test against Samba4\n"); - return True; - } - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); - printf("Testing netr_DsrGetDcSiteCoverageW\n"); + status = dcerpc_netr_DsrGetDcSiteCoverageW(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "failed"); + torture_assert_werr_ok(tctx, r.out.result, "failed"); - status = dcerpc_netr_DsrGetDcSiteCoverageW(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { - printf("netr_DsrGetDcSiteCoverageW - %s/%s\n", - nt_errstr(status), win_errstr(r.out.result)); - ret = False; - } - return ret; + return true; } -static BOOL test_GetDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_GetDomainInfo(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *machine_credentials) { NTSTATUS status; struct netr_LogonGetDomainInfo r; @@ -1401,16 +1187,16 @@ static BOOL test_GetDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) struct netr_Authenticator a; struct creds_CredentialState *creds; - if (!test_SetupCredentials3(p, mem_ctx, NETLOGON_NEG_AUTH2_ADS_FLAGS, - TEST_MACHINE_NAME, machine_password, &creds)) { - return False; + if (!test_SetupCredentials3(p, tctx, NETLOGON_NEG_AUTH2_ADS_FLAGS, + machine_credentials, &creds)) { + return false; } ZERO_STRUCT(r); creds_client_authenticator(creds, &a); - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.computer_name = TEST_MACHINE_NAME; r.in.level = 1; r.in.credential = &a; @@ -1428,32 +1214,27 @@ static BOOL test_GetDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) q1.blob2.data = NULL; q1.product.string = "product string"; - printf("Testing netr_LogonGetDomainInfo\n"); + torture_comment(tctx, "Testing netr_uogonGetDomainInfo\n"); - status = dcerpc_netr_LogonGetDomainInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("netr_LogonGetDomainInfo - %s\n", nt_errstr(status)); - return False; - } - - if (!creds_client_check(creds, &a.cred)) { - printf("Credential chaining failed\n"); - return False; - } + status = dcerpc_netr_LogonGetDomainInfo(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "netr_LogonGetDomainInfo"); + torture_assert(tctx, creds_client_check(creds, &a.cred), "Credential chaining failed"); - return True; + return true; } static void async_callback(struct rpc_request *req) { - int *counter = req->async.private_data; + int *counter = (int *)req->async.private_data; if (NT_STATUS_IS_OK(req->status)) { (*counter)++; } } -static BOOL test_GetDomainInfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_GetDomainInfo_async(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *machine_credentials) { NTSTATUS status; struct netr_LogonGetDomainInfo r; @@ -1464,20 +1245,15 @@ static BOOL test_GetDomainInfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) struct creds_CredentialState *creds_async[ASYNC_COUNT]; struct rpc_request *req[ASYNC_COUNT]; int i; - int *async_counter = talloc(mem_ctx, int); - - if (!lp_parm_bool(-1, "torture", "dangerous", False)) { - printf("test_GetDomainInfo_async disabled - enable dangerous tests to use\n"); - return True; - } + int *async_counter = talloc(tctx, int); - if (!test_SetupCredentials3(p, mem_ctx, NETLOGON_NEG_AUTH2_ADS_FLAGS, - TEST_MACHINE_NAME, machine_password, &creds)) { - return False; + if (!test_SetupCredentials3(p, tctx, NETLOGON_NEG_AUTH2_ADS_FLAGS, + machine_credentials, &creds)) { + return false; } ZERO_STRUCT(r); - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.computer_name = TEST_MACHINE_NAME; r.in.level = 1; r.in.credential = &a; @@ -1495,46 +1271,45 @@ static BOOL test_GetDomainInfo_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) q1.blob2.data = NULL; q1.product.string = "product string"; - printf("Testing netr_LogonGetDomainInfo - async count %d\n", ASYNC_COUNT); + torture_comment(tctx, "Testing netr_LogonGetDomainInfo - async count %d\n", ASYNC_COUNT); *async_counter = 0; for (i=0;i<ASYNC_COUNT;i++) { creds_client_authenticator(creds, &a); - creds_async[i] = talloc_memdup(creds, creds, sizeof(*creds)); - req[i] = dcerpc_netr_LogonGetDomainInfo_send(p, mem_ctx, &r); + creds_async[i] = (struct creds_CredentialState *)talloc_memdup(creds, creds, sizeof(*creds)); + req[i] = dcerpc_netr_LogonGetDomainInfo_send(p, tctx, &r); req[i]->async.callback = async_callback; req[i]->async.private_data = async_counter; /* even with this flush per request a w2k3 server seems to clag with multiple outstanding requests. bleergh. */ - if (event_loop_once(dcerpc_event_context(p)) != 0) { - return False; - } + torture_assert_int_equal(tctx, event_loop_once(dcerpc_event_context(p)), 0, + "event_loop_once failed"); } for (i=0;i<ASYNC_COUNT;i++) { status = dcerpc_ndr_request_recv(req[i]); - if (!NT_STATUS_IS_OK(status) || !NT_STATUS_IS_OK(r.out.result)) { - printf("netr_LogonGetDomainInfo_async(%d) - %s/%s\n", - i, nt_errstr(status), nt_errstr(r.out.result)); - break; - } - if (!creds_client_check(creds_async[i], &a.cred)) { - printf("Credential chaining failed at async %d\n", i); - break; - } + torture_assert_ntstatus_ok(tctx, status, "netr_LogonGetDomainInfo_async"); + torture_assert_ntstatus_ok(tctx, r.out.result, "netr_LogonGetDomainInfo_async"); + + torture_assert(tctx, creds_client_check(creds_async[i], &a.cred), + "Credential chaining failed at async"); } - printf("Testing netr_LogonGetDomainInfo - async count %d OK\n", *async_counter); + torture_comment(tctx, + "Testing netr_LogonGetDomainInfo - async count %d OK\n", *async_counter); + + torture_assert_int_equal(tctx, (*async_counter), ASYNC_COUNT, "int"); - return (*async_counter) == ASYNC_COUNT; + return true; } -static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_ManyGetDCName(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct dcerpc_pipe *p2; @@ -1549,25 +1324,18 @@ static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) struct netr_GetAnyDCName d; int i; - BOOL ret = True; if (p->conn->transport.transport != NCACN_NP) { - return True; + return true; } - printf("Torturing GetDCName\n"); + torture_comment(tctx, "Torturing GetDCName\n"); status = dcerpc_secondary_connection(p, &p2, p->binding); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to create secondary connection\n"); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "Failed to create secondary connection"); status = dcerpc_bind_auth_none(p2, &ndr_table_lsarpc); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to create bind on secondary connection\n"); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "Failed to create bind on secondary connection"); qos.len = 0; qos.impersonation_level = 2; @@ -1586,11 +1354,8 @@ static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) o.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; o.out.handle = &lsa_handle; - status = dcerpc_lsa_OpenPolicy2(p2, mem_ctx, &o); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenPolicy2 failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_lsa_OpenPolicy2(p2, tctx, &o); + torture_assert_ntstatus_ok(tctx, status, "OpenPolicy2 failed"); t.in.handle = &lsa_handle; t.in.resume_handle = &resume_handle; @@ -1598,17 +1363,15 @@ static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) t.out.domains = &domains; t.out.resume_handle = &resume_handle; - status = dcerpc_lsa_EnumTrustDom(p2, mem_ctx, &t); + status = dcerpc_lsa_EnumTrustDom(p2, tctx, &t); if ((!NT_STATUS_IS_OK(status) && - (!NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)))) { - printf("Could not list domains\n"); - return False; - } + (!NT_STATUS_EQUAL(status, NT_STATUS_NO_MORE_ENTRIES)))) + torture_fail(tctx, "Could not list domains"); talloc_free(p2); - d.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", + d.in.logon_server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); for (i=0; i<domains.count * 4; i++) { @@ -1617,74 +1380,49 @@ static BOOL test_ManyGetDCName(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) d.in.domainname = info->name.string; - status = dcerpc_netr_GetAnyDCName(p, mem_ctx, &d); - if (!NT_STATUS_IS_OK(status)) { - printf("GetAnyDCName - %s\n", nt_errstr(status)); - continue; - } + status = dcerpc_netr_GetAnyDCName(p, tctx, &d); + torture_assert_ntstatus_ok(tctx, status, "GetAnyDCName"); - printf("\tDC for domain %s is %s\n", info->name.string, + torture_comment(tctx, "\tDC for domain %s is %s\n", info->name.string, d.out.dcname ? d.out.dcname : "unknown"); } - return ret; + return true; } - -BOOL torture_rpc_netlogon(struct torture_context *torture) +struct torture_suite *torture_rpc_netlogon(TALLOC_CTX *mem_ctx) { - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - struct test_join *join_ctx; - struct cli_credentials *machine_credentials; - - mem_ctx = talloc_init("torture_rpc_netlogon"); - - join_ctx = torture_join_domain(TEST_MACHINE_NAME, ACB_SVRTRUST, - &machine_credentials); - if (!join_ctx) { - talloc_free(mem_ctx); - printf("Failed to join as BDC\n"); - return False; - } - - machine_password = cli_credentials_get_password(machine_credentials); - - status = torture_rpc_connection(torture, &p, &ndr_table_netlogon); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } - - ret &= test_LogonUasLogon(p, mem_ctx); - ret &= test_LogonUasLogoff(p, mem_ctx); - ret &= test_SamLogon(p, mem_ctx, machine_credentials); - ret &= test_SetPassword(p, mem_ctx); - ret &= test_SetPassword2(p, mem_ctx); - ret &= test_GetDomainInfo(p, mem_ctx); - ret &= test_DatabaseSync(p, mem_ctx); - ret &= test_DatabaseDeltas(p, mem_ctx); - ret &= test_AccountDeltas(p, mem_ctx); - ret &= test_AccountSync(p, mem_ctx); - ret &= test_GetDcName(p, mem_ctx); - ret &= test_ManyGetDCName(p, mem_ctx); - ret &= test_LogonControl(p, mem_ctx); - ret &= test_GetAnyDCName(p, mem_ctx); - ret &= test_LogonControl2(p, mem_ctx); - ret &= test_DatabaseSync2(p, mem_ctx); - ret &= test_LogonControl2Ex(p, mem_ctx); - ret &= test_DsrEnumerateDomainTrusts(p, mem_ctx); - ret &= test_GetDomainInfo_async(p, mem_ctx); - ret &= test_netr_DsRGetDCName(p, mem_ctx); - ret &= test_netr_DsRGetDCNameEx(p, mem_ctx); - ret &= test_netr_DsRGetDCNameEx2(p, mem_ctx); - ret &= test_netr_DsrGetDcSiteCoverageW(p, mem_ctx); - - talloc_free(mem_ctx); - - torture_leave_domain(join_ctx); - - return ret; + struct torture_suite *suite = torture_suite_create(mem_ctx, "NETLOGON"); + struct torture_rpc_tcase *tcase; + struct torture_test *test; + + tcase = torture_suite_add_machine_rpc_iface_tcase(suite, "netlogon", + &ndr_table_netlogon, TEST_MACHINE_NAME); + + torture_rpc_tcase_add_test(tcase, "LogonUasLogon", test_LogonUasLogon); + torture_rpc_tcase_add_test(tcase, "LogonUasLogoff", test_LogonUasLogoff); + torture_rpc_tcase_add_test_creds(tcase, "SamLogon", test_SamLogon); + torture_rpc_tcase_add_test_creds(tcase, "SetPassword", test_SetPassword); + torture_rpc_tcase_add_test_creds(tcase, "SetPassword2", test_SetPassword2); + torture_rpc_tcase_add_test_creds(tcase, "GetDomainInfo", test_GetDomainInfo); + torture_rpc_tcase_add_test_creds(tcase, "DatabaseSync", test_DatabaseSync); + torture_rpc_tcase_add_test_creds(tcase, "DatabaseDeltas", test_DatabaseDeltas); + torture_rpc_tcase_add_test_creds(tcase, "AccountDeltas", test_AccountDeltas); + torture_rpc_tcase_add_test_creds(tcase, "AccountSync", test_AccountSync); + torture_rpc_tcase_add_test(tcase, "GetDcName", test_GetDcName); + torture_rpc_tcase_add_test(tcase, "ManyGetDCName", test_ManyGetDCName); + torture_rpc_tcase_add_test(tcase, "LogonControl", test_LogonControl); + torture_rpc_tcase_add_test(tcase, "GetAnyDCName", test_GetAnyDCName); + torture_rpc_tcase_add_test(tcase, "LogonControl2", test_LogonControl2); + torture_rpc_tcase_add_test_creds(tcase, "DatabaseSync2", test_DatabaseSync2); + torture_rpc_tcase_add_test(tcase, "LogonControl2Ex", test_LogonControl2Ex); + torture_rpc_tcase_add_test(tcase, "DsrEnumerateDomainTrusts", test_DsrEnumerateDomainTrusts); + test = torture_rpc_tcase_add_test_creds(tcase, "GetDomainInfo_async", test_GetDomainInfo_async); + test->dangerous = true; + torture_rpc_tcase_add_test(tcase, "DsRGetDCName", test_netr_DsRGetDCName); + torture_rpc_tcase_add_test(tcase, "DsRGetDCNameEx", test_netr_DsRGetDCNameEx); + torture_rpc_tcase_add_test(tcase, "DsRGetDCNameEx2", test_netr_DsRGetDCNameEx2); + torture_rpc_tcase_add_test(tcase, "DsrGetDcSiteCoverageW", test_netr_DsrGetDcSiteCoverageW); + + return suite; } diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c index af7e05a9f0..6891783a82 100644 --- a/source4/torture/rpc/rpc.c +++ b/source4/torture/rpc/rpc.c @@ -27,33 +27,49 @@ #include "librpc/ndr/ndr_table.h" #include "lib/util/dlinklist.h" -struct torture_rpc_tcase { - struct torture_tcase tcase; - const struct ndr_interface_table *table; - struct dcerpc_pipe *pipe; -}; +static bool torture_rpc_teardown (struct torture_context *tcase, + void *data) +{ + struct torture_rpc_tcase_data *tcase_data = + (struct torture_rpc_tcase_data *)data; + if (tcase_data->join_ctx != NULL) + torture_leave_domain(tcase_data->join_ctx); + talloc_free(tcase_data); + return true; +} +/** + * Obtain the DCE/RPC binding context associated with a torture context. + * + * @param tctx Torture context + * @param binding Pointer to store DCE/RPC binding + */ NTSTATUS torture_rpc_binding(struct torture_context *tctx, - struct dcerpc_binding **binding) + struct dcerpc_binding **binding) { NTSTATUS status; - const char *binding_string = torture_setting_string(tctx, "binding", NULL); + const char *binding_string = torture_setting_string(tctx, "binding", + NULL); if (binding_string == NULL) { - torture_comment(tctx, "You must specify a ncacn binding string\n"); + torture_comment(tctx, + "You must specify a DCE/RPC binding string\n"); return NT_STATUS_INVALID_PARAMETER; } status = dcerpc_parse_binding(tctx, binding_string, binding); if (NT_STATUS_IS_ERR(status)) { - DEBUG(0,("Failed to parse dcerpc binding '%s'\n", binding_string)); + DEBUG(0,("Failed to parse dcerpc binding '%s'\n", + binding_string)); return status; } return NT_STATUS_OK; } -/* open a rpc connection to the chosen binding string */ +/** + * open a rpc connection to the chosen binding string + */ _PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx, struct dcerpc_pipe **p, const struct ndr_interface_table *table) @@ -77,16 +93,17 @@ _PUBLIC_ NTSTATUS torture_rpc_connection(struct torture_context *tctx, return status; } -/* open a rpc connection to a specific transport */ +/** + * open a rpc connection to a specific transport + */ NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx, struct dcerpc_pipe **p, const struct ndr_interface_table *table, enum dcerpc_transport_t transport, uint32_t assoc_group_id) { - NTSTATUS status; + NTSTATUS status; struct dcerpc_binding *binding; - TALLOC_CTX *mem_ctx = talloc_named(tctx, 0, "torture_rpc_connection_smb"); status = torture_rpc_binding(tctx, &binding); if (NT_STATUS_IS_ERR(status)) @@ -95,38 +112,100 @@ NTSTATUS torture_rpc_connection_transport(struct torture_context *tctx, binding->transport = transport; binding->assoc_group_id = assoc_group_id; - status = dcerpc_pipe_connect_b(mem_ctx, p, binding, table, + status = dcerpc_pipe_connect_b(tctx, p, binding, table, cmdline_credentials, NULL); - if (NT_STATUS_IS_OK(status)) { - *p = talloc_reference(tctx, *p); - } else { + if (NT_STATUS_IS_ERR(status)) { *p = NULL; } - talloc_free(mem_ctx); + return status; } +static bool torture_rpc_setup_machine(struct torture_context *tctx, + void **data) +{ + NTSTATUS status; + struct dcerpc_binding *binding; + struct torture_rpc_tcase *tcase = talloc_get_type(tctx->active_tcase, + struct torture_rpc_tcase); + struct torture_rpc_tcase_data *tcase_data; + + status = torture_rpc_binding(tctx, &binding); + if (NT_STATUS_IS_ERR(status)) + return false; + + *data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data); + tcase_data->credentials = cmdline_credentials; + tcase_data->join_ctx = torture_join_domain(tcase->machine_name, + ACB_SVRTRUST, + &tcase_data->credentials); + if (tcase_data->join_ctx == NULL) + torture_fail(tctx, "Failed to join as BDC"); + + status = dcerpc_pipe_connect_b(tctx, + &(tcase_data->pipe), + binding, + tcase->table, + tcase_data->credentials, NULL); + + torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); + + return true; +} + +_PUBLIC_ struct torture_rpc_tcase *torture_suite_add_machine_rpc_iface_tcase( + struct torture_suite *suite, + const char *name, + const struct ndr_interface_table *table, + const char *machine_name) +{ + struct torture_rpc_tcase *tcase = talloc(suite, + struct torture_rpc_tcase); + + torture_suite_init_rpc_tcase(suite, tcase, name, table); + + tcase->machine_name = talloc_strdup(tcase, machine_name); + tcase->tcase.setup = torture_rpc_setup_machine; + tcase->tcase.teardown = torture_rpc_teardown; + + return tcase; +} + +_PUBLIC_ bool torture_suite_init_rpc_tcase(struct torture_suite *suite, + struct torture_rpc_tcase *tcase, + const char *name, + const struct ndr_interface_table *table) +{ + if (!torture_suite_init_tcase(suite, (struct torture_tcase *)tcase, name)) + return false; + + tcase->table = table; + + return true; +} + static bool torture_rpc_setup_anonymous(struct torture_context *tctx, - void **data) + void **data) { - struct cli_credentials *anon_credentials; NTSTATUS status; struct dcerpc_binding *binding; - struct torture_rpc_tcase *tcase = talloc_get_type( - tctx->active_tcase, struct torture_rpc_tcase); + struct torture_rpc_tcase_data *tcase_data; + struct torture_rpc_tcase *tcase = talloc_get_type(tctx->active_tcase, + struct torture_rpc_tcase); status = torture_rpc_binding(tctx, &binding); if (NT_STATUS_IS_ERR(status)) return false; - anon_credentials = cli_credentials_init_anon(tctx); + *data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data); + tcase_data->credentials = cli_credentials_init_anon(tctx); status = dcerpc_pipe_connect_b(tctx, - (struct dcerpc_pipe **)data, + &(tcase_data->pipe), binding, tcase->table, - anon_credentials, NULL); + tcase_data->credentials, NULL); torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); @@ -138,21 +217,21 @@ static bool torture_rpc_setup (struct torture_context *tctx, void **data) NTSTATUS status; struct torture_rpc_tcase *tcase = talloc_get_type( tctx->active_tcase, struct torture_rpc_tcase); + struct torture_rpc_tcase_data *tcase_data; + + *data = tcase_data = talloc_zero(tctx, struct torture_rpc_tcase_data); + tcase_data->credentials = cmdline_credentials; status = torture_rpc_connection(tctx, - (struct dcerpc_pipe **)data, - (const struct ndr_interface_table *)tcase->table); + &(tcase_data->pipe), + tcase->table); torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); return true; } -static bool torture_rpc_teardown (struct torture_context *tcase, void *data) -{ - talloc_free(data); - return true; -} + _PUBLIC_ struct torture_rpc_tcase *torture_suite_add_anon_rpc_iface_tcase(struct torture_suite *suite, const char *name, @@ -160,11 +239,10 @@ _PUBLIC_ struct torture_rpc_tcase *torture_suite_add_anon_rpc_iface_tcase(struct { struct torture_rpc_tcase *tcase = talloc(suite, struct torture_rpc_tcase); - torture_suite_init_tcase(suite, (struct torture_tcase *)tcase, name); + torture_suite_init_rpc_tcase(suite, tcase, name, table); tcase->tcase.setup = torture_rpc_setup_anonymous; tcase->tcase.teardown = torture_rpc_teardown; - tcase->table = table; return tcase; } @@ -176,11 +254,10 @@ _PUBLIC_ struct torture_rpc_tcase *torture_suite_add_rpc_iface_tcase(struct tort { struct torture_rpc_tcase *tcase = talloc(suite, struct torture_rpc_tcase); - torture_suite_init_tcase(suite, (struct torture_tcase *)tcase, name); + torture_suite_init_rpc_tcase(suite, tcase, name, table); tcase->tcase.setup = torture_rpc_setup; tcase->tcase.teardown = torture_rpc_teardown; - tcase->table = table; return tcase; } @@ -190,10 +267,12 @@ static bool torture_rpc_wrap_test(struct torture_context *tctx, struct torture_test *test) { bool (*fn) (struct torture_context *, struct dcerpc_pipe *); + struct torture_rpc_tcase_data *tcase_data = + (struct torture_rpc_tcase_data *)tcase->data; fn = test->fn; - return fn(tctx, (struct dcerpc_pipe *)tcase->data); + return fn(tctx, tcase_data->pipe); } static bool torture_rpc_wrap_test_ex(struct torture_context *tctx, @@ -201,10 +280,26 @@ static bool torture_rpc_wrap_test_ex(struct torture_context *tctx, struct torture_test *test) { bool (*fn) (struct torture_context *, struct dcerpc_pipe *, const void *); + struct torture_rpc_tcase_data *tcase_data = + (struct torture_rpc_tcase_data *)tcase->data; + + fn = test->fn; + + return fn(tctx, tcase_data->pipe, test->data); +} + + +static bool torture_rpc_wrap_test_creds(struct torture_context *tctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct cli_credentials *); + struct torture_rpc_tcase_data *tcase_data = + (struct torture_rpc_tcase_data *)tcase->data; fn = test->fn; - return fn(tctx, (struct dcerpc_pipe *)tcase->data, test->data); + return fn(tctx, tcase_data->pipe, tcase_data->credentials); } _PUBLIC_ struct torture_test *torture_rpc_tcase_add_test( @@ -228,6 +323,27 @@ _PUBLIC_ struct torture_test *torture_rpc_tcase_add_test( return test; } +_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test_creds( + struct torture_rpc_tcase *tcase, + const char *name, + bool (*fn) (struct torture_context *, struct dcerpc_pipe *, struct cli_credentials *)) +{ + struct torture_test *test; + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = torture_rpc_wrap_test_creds; + test->dangerous = false; + test->data = NULL; + test->fn = fn; + + DLIST_ADD(tcase->tcase.tests, test); + + return test; +} + _PUBLIC_ struct torture_test *torture_rpc_tcase_add_test_ex( struct torture_rpc_tcase *tcase, const char *name, @@ -262,26 +378,28 @@ NTSTATUS torture_rpc_init(void) torture_suite_add_simple_test(suite, "LSA", torture_rpc_lsa); torture_suite_add_simple_test(suite, "LSALOOKUP", torture_rpc_lsa_lookup); torture_suite_add_simple_test(suite, "LSA-GETUSER", torture_rpc_lsa_get_user); - torture_suite_add_simple_test(suite, "SECRETS", torture_rpc_lsa_secrets); - torture_suite_add_suite(suite, torture_rpc_echo()); + torture_suite_add_suite(suite, torture_rpc_lsa_secrets(suite)); + torture_suite_add_suite(suite, torture_rpc_echo(suite)); torture_suite_add_simple_test(suite, "DFS", torture_rpc_dfs); - torture_suite_add_suite(suite, torture_rpc_unixinfo()); - torture_suite_add_suite(suite, torture_rpc_eventlog()); - torture_suite_add_suite(suite, torture_rpc_atsvc()); + torture_suite_add_suite(suite, torture_rpc_unixinfo(suite)); + torture_suite_add_suite(suite, torture_rpc_eventlog(suite)); + torture_suite_add_suite(suite, torture_rpc_atsvc(suite)); torture_suite_add_suite(suite, torture_rpc_wkssvc(suite)); torture_suite_add_suite(suite, torture_rpc_handles(suite)); torture_suite_add_suite(suite, torture_rpc_winreg(suite)); torture_suite_add_simple_test(suite, "SPOOLSS", torture_rpc_spoolss); + torture_suite_add_suite(suite, torture_rpc_spoolss_notify(suite)); torture_suite_add_simple_test(suite, "SAMR", torture_rpc_samr); torture_suite_add_simple_test(suite, "SAMR-USERS", torture_rpc_samr_users); torture_suite_add_simple_test(suite, "SAMR-PASSWORDS", torture_rpc_samr_passwords); - torture_suite_add_simple_test(suite, "NETLOGON", torture_rpc_netlogon); + torture_suite_add_suite(suite, torture_rpc_netlogon(suite)); torture_suite_add_simple_test(suite, "SAMLOGON", torture_rpc_samlogon); torture_suite_add_simple_test(suite, "SAMSYNC", torture_rpc_samsync); torture_suite_add_simple_test(suite, "SCHANNEL", torture_rpc_schannel); torture_suite_add_simple_test(suite, "SCHANNEL2", torture_rpc_schannel2); torture_suite_add_suite(suite, torture_rpc_srvsvc(suite)); torture_suite_add_suite(suite, torture_rpc_svcctl(suite)); + torture_suite_add_suite(suite, torture_rpc_samr_accessmask(suite)); torture_suite_add_suite(suite, torture_rpc_epmapper(suite)); torture_suite_add_suite(suite, torture_rpc_initshutdown(suite)); torture_suite_add_suite(suite, torture_rpc_oxidresolve(suite)); @@ -303,10 +421,10 @@ NTSTATUS torture_rpc_init(void) torture_suite_add_simple_test(suite, "SAMBA3-LSA", torture_samba3_rpc_lsa); torture_suite_add_simple_test(suite, "SAMBA3-SPOOLSS", torture_samba3_rpc_spoolss); torture_suite_add_simple_test(suite, "SAMBA3-WKSSVC", torture_samba3_rpc_wkssvc); - torture_suite_add_simple_test(suite, "RPC-SAMBA3-WINREG", torture_samba3_rpc_winreg); + torture_suite_add_simple_test(suite, "SAMBA3-WINREG", torture_samba3_rpc_winreg); torture_suite_add_simple_test(suite, "DRSUAPI", torture_rpc_drsuapi); torture_suite_add_simple_test(suite, "CRACKNAMES", torture_rpc_drsuapi_cracknames); - torture_suite_add_simple_test(suite, "DSSETUP", torture_rpc_dssetup); + torture_suite_add_suite(suite, torture_rpc_dssetup(suite)); torture_suite_add_simple_test(suite, "ALTERCONTEXT", torture_rpc_alter_context); torture_suite_add_simple_test(suite, "JOIN", torture_rpc_join); torture_suite_add_simple_test(suite, "DSSYNC", torture_rpc_dssync); diff --git a/source4/torture/rpc/rpc.h b/source4/torture/rpc/rpc.h index 2f1ff323eb..385c734d9c 100644 --- a/source4/torture/rpc/rpc.h +++ b/source4/torture/rpc/rpc.h @@ -30,4 +30,18 @@ #include "torture/rpc/proto.h" #include "torture/ui.h" +struct torture_rpc_tcase { + struct torture_tcase tcase; + const struct ndr_interface_table *table; + const char *machine_name; +}; + +struct torture_rpc_tcase_data { + struct test_join *join_ctx; + struct dcerpc_pipe *pipe; + struct cli_credentials *credentials; +}; + + + #endif /* __TORTURE_RPC_H__ */ diff --git a/source4/torture/rpc/samba3rpc.c b/source4/torture/rpc/samba3rpc.c index 72eba40344..8c52199e66 100644 --- a/source4/torture/rpc/samba3rpc.c +++ b/source4/torture/rpc/samba3rpc.c @@ -48,6 +48,7 @@ #include "libcli/auth/libcli_auth.h" #include "lib/crypto/crypto.h" #include "libcli/security/proto.h" +#include "param/param.h" static struct cli_credentials *create_anon_creds(TALLOC_CTX *mem_ctx) { @@ -57,7 +58,7 @@ static struct cli_credentials *create_anon_creds(TALLOC_CTX *mem_ctx) return NULL; } - cli_credentials_set_conf(result); + cli_credentials_set_conf(result, global_loadparm); cli_credentials_set_anonymous(result); return result; @@ -67,11 +68,11 @@ static struct cli_credentials *create_anon_creds(TALLOC_CTX *mem_ctx) * This tests a RPC call using an invalid vuid */ -BOOL torture_bind_authcontext(struct torture_context *torture) +bool torture_bind_authcontext(struct torture_context *torture) { TALLOC_CTX *mem_ctx; NTSTATUS status; - BOOL ret = False; + bool ret = false; struct lsa_ObjectAttribute objectattr; struct lsa_OpenPolicy2 openpolicy; struct policy_handle handle; @@ -87,7 +88,7 @@ BOOL torture_bind_authcontext(struct torture_context *torture) if (mem_ctx == NULL) { d_printf("talloc_init failed\n"); - return False; + return false; } status = smbcli_full_connection(mem_ctx, &cli, @@ -145,7 +146,7 @@ BOOL torture_bind_authcontext(struct torture_context *torture) goto done; } - session2 = smbcli_session_init(cli->transport, mem_ctx, False); + session2 = smbcli_session_init(cli->transport, mem_ctx, false); if (session2 == NULL) { d_printf("smbcli_session_init failed\n"); goto done; @@ -185,7 +186,7 @@ BOOL torture_bind_authcontext(struct torture_context *torture) goto done; } - ret = True; + ret = true; done: talloc_free(mem_ctx); return ret; @@ -195,12 +196,12 @@ BOOL torture_bind_authcontext(struct torture_context *torture) * Bind to lsa using a specific auth method */ -static BOOL bindtest(struct smbcli_state *cli, +static bool bindtest(struct smbcli_state *cli, struct cli_credentials *credentials, uint8_t auth_type, uint8_t auth_level) { TALLOC_CTX *mem_ctx; - BOOL ret = False; + bool ret = false; NTSTATUS status; struct dcerpc_pipe *lsa_pipe; @@ -212,7 +213,7 @@ static BOOL bindtest(struct smbcli_state *cli, if ((mem_ctx = talloc_init("bindtest")) == NULL) { d_printf("talloc_init failed\n"); - return False; + return false; } lsa_pipe = dcerpc_pipe_init(mem_ctx, @@ -272,7 +273,7 @@ static BOOL bindtest(struct smbcli_state *cli, goto done; } - ret = True; + ret = true; done: talloc_free(mem_ctx); return ret; @@ -282,18 +283,18 @@ static BOOL bindtest(struct smbcli_state *cli, * test authenticated RPC binds with the variants Samba3 does support */ -BOOL torture_bind_samba3(struct torture_context *torture) +bool torture_bind_samba3(struct torture_context *torture) { TALLOC_CTX *mem_ctx; NTSTATUS status; - BOOL ret = False; + bool ret = false; struct smbcli_state *cli; mem_ctx = talloc_init("torture_bind_authcontext"); if (mem_ctx == NULL) { d_printf("talloc_init failed\n"); - return False; + return false; } status = smbcli_full_connection(mem_ctx, &cli, @@ -306,7 +307,7 @@ BOOL torture_bind_samba3(struct torture_context *torture) goto done; } - ret = True; + ret = true; ret &= bindtest(cli, cmdline_credentials, DCERPC_AUTH_TYPE_NTLMSSP, DCERPC_AUTH_LEVEL_INTEGRITY); @@ -501,7 +502,7 @@ static NTSTATUS get_usr_handle(struct smbcli_state *cli, * Create a test user */ -static BOOL create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, +static bool create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, struct cli_credentials *admin_creds, const char *username, const char *password, char **domain_name, @@ -511,11 +512,11 @@ static BOOL create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, NTSTATUS status; struct dcerpc_pipe *samr_pipe; struct policy_handle *wks_handle; - BOOL ret = False; + bool ret = false; if (!(tmp_ctx = talloc_new(mem_ctx))) { d_printf("talloc_init failed\n"); - return False; + return false; } status = get_usr_handle(cli, tmp_ctx, admin_creds, @@ -603,7 +604,7 @@ static BOOL create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, *domain_name= talloc_steal(mem_ctx, *domain_name); *user_sid = talloc_steal(mem_ctx, *user_sid); - ret = True; + ret = true; done: talloc_free(tmp_ctx); return ret; @@ -613,7 +614,7 @@ static BOOL create_user(TALLOC_CTX *mem_ctx, struct smbcli_state *cli, * Delete a test user */ -static BOOL delete_user(struct smbcli_state *cli, +static bool delete_user(struct smbcli_state *cli, struct cli_credentials *admin_creds, const char *username) { @@ -622,11 +623,11 @@ static BOOL delete_user(struct smbcli_state *cli, char *dom_name; struct dcerpc_pipe *samr_pipe; struct policy_handle *user_handle; - BOOL ret = False; + bool ret = false; if ((mem_ctx = talloc_init("leave")) == NULL) { d_printf("talloc_init failed\n"); - return False; + return false; } status = get_usr_handle(cli, mem_ctx, admin_creds, @@ -648,12 +649,12 @@ static BOOL delete_user(struct smbcli_state *cli, status = dcerpc_samr_DeleteUser(samr_pipe, mem_ctx, &d); if (!NT_STATUS_IS_OK(status)) { - d_printf("samr_DeleteUser failed\n"); + d_printf("samr_DeleteUser failed %s\n", nt_errstr(status)); goto done; } } - ret = True; + ret = true; done: talloc_free(mem_ctx); @@ -664,8 +665,8 @@ static BOOL delete_user(struct smbcli_state *cli, * Do a Samba3-style join */ -static BOOL join3(struct smbcli_state *cli, - BOOL use_level25, +static bool join3(struct smbcli_state *cli, + bool use_level25, struct cli_credentials *admin_creds, struct cli_credentials *wks_creds) { @@ -674,11 +675,11 @@ static BOOL join3(struct smbcli_state *cli, char *dom_name; struct dcerpc_pipe *samr_pipe; struct policy_handle *wks_handle; - BOOL ret = False; + bool ret = false; if ((mem_ctx = talloc_init("join3")) == NULL) { d_printf("talloc_init failed\n"); - return False; + return false; } status = get_usr_handle( @@ -787,7 +788,7 @@ static BOOL join3(struct smbcli_state *cli, } } - ret = True; + ret = true; done: talloc_free(mem_ctx); @@ -798,12 +799,12 @@ static BOOL join3(struct smbcli_state *cli, * Do a ReqChallenge/Auth2 and get the wks creds */ -static BOOL auth2(struct smbcli_state *cli, +static bool auth2(struct smbcli_state *cli, struct cli_credentials *wks_cred) { TALLOC_CTX *mem_ctx; struct dcerpc_pipe *net_pipe; - BOOL result = False; + bool result = false; NTSTATUS status; struct netr_ServerReqChallenge r; struct netr_Credential netr_cli_creds; @@ -817,7 +818,7 @@ static BOOL auth2(struct smbcli_state *cli, mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { d_printf("talloc_new failed\n"); - return False; + return false; } net_pipe = dcerpc_pipe_init(mem_ctx, @@ -893,7 +894,7 @@ static BOOL auth2(struct smbcli_state *cli, cli_credentials_set_netlogon_creds(wks_cred, creds_state); - result = True; + result = true; done: talloc_free(mem_ctx); @@ -905,20 +906,20 @@ static BOOL auth2(struct smbcli_state *cli, * login, and change the wks password */ -static BOOL schan(struct smbcli_state *cli, +static bool schan(struct smbcli_state *cli, struct cli_credentials *wks_creds, struct cli_credentials *user_creds) { TALLOC_CTX *mem_ctx; NTSTATUS status; - BOOL ret = False; + bool ret = false; struct dcerpc_pipe *net_pipe; int i; mem_ctx = talloc_new(NULL); if (mem_ctx == NULL) { d_printf("talloc_new failed\n"); - return False; + return false; } net_pipe = dcerpc_pipe_init(mem_ctx, @@ -1092,7 +1093,7 @@ static BOOL schan(struct smbcli_state *cli, CRED_SPECIFIED); } - ret = True; + ret = true; done: talloc_free(mem_ctx); return ret; @@ -1102,13 +1103,13 @@ static BOOL schan(struct smbcli_state *cli, * Delete the wks account again */ -static BOOL leave(struct smbcli_state *cli, +static bool leave(struct smbcli_state *cli, struct cli_credentials *admin_creds, struct cli_credentials *wks_creds) { char *wks_name = talloc_asprintf( NULL, "%s$", cli_credentials_get_workstation(wks_creds)); - BOOL ret; + bool ret; ret = delete_user(cli, admin_creds, wks_name); talloc_free(wks_name); @@ -1119,11 +1120,11 @@ static BOOL leave(struct smbcli_state *cli, * Test the Samba3 DC code a bit. Join, do some schan netlogon ops, leave */ -BOOL torture_netlogon_samba3(struct torture_context *torture) +bool torture_netlogon_samba3(struct torture_context *torture) { TALLOC_CTX *mem_ctx; NTSTATUS status; - BOOL ret = False; + bool ret = false; struct smbcli_state *cli; struct cli_credentials *anon_creds; struct cli_credentials *wks_creds; @@ -1139,7 +1140,7 @@ BOOL torture_netlogon_samba3(struct torture_context *torture) if (mem_ctx == NULL) { d_printf("talloc_init failed\n"); - return False; + return false; } if (!(anon_creds = create_anon_creds(mem_ctx))) { @@ -1162,7 +1163,7 @@ BOOL torture_netlogon_samba3(struct torture_context *torture) goto done; } - cli_credentials_set_conf(wks_creds); + cli_credentials_set_conf(wks_creds, global_loadparm); cli_credentials_set_secure_channel_type(wks_creds, SEC_CHAN_WKSTA); cli_credentials_set_username(wks_creds, wks_name, CRED_SPECIFIED); cli_credentials_set_workstation(wks_creds, wks_name, CRED_SPECIFIED); @@ -1170,7 +1171,7 @@ BOOL torture_netlogon_samba3(struct torture_context *torture) generate_random_str(wks_creds, 8), CRED_SPECIFIED); - if (!join3(cli, False, cmdline_credentials, wks_creds)) { + if (!join3(cli, false, cmdline_credentials, wks_creds)) { d_printf("join failed\n"); goto done; } @@ -1205,7 +1206,7 @@ BOOL torture_netlogon_samba3(struct torture_context *torture) goto done; } - ret = True; + ret = true; done: talloc_free(mem_ctx); @@ -1217,19 +1218,19 @@ BOOL torture_netlogon_samba3(struct torture_context *torture) * credentials */ -static BOOL test_join3(TALLOC_CTX *mem_ctx, - BOOL use_level25, +static bool test_join3(TALLOC_CTX *mem_ctx, + bool use_level25, struct cli_credentials *smb_creds, struct cli_credentials *samr_creds, const char *wks_name) { NTSTATUS status; - BOOL ret = False; + bool ret = false; struct smbcli_state *cli; struct cli_credentials *wks_creds; status = smbcli_full_connection(mem_ctx, &cli, - lp_parm_string(-1, "torture", "host"), + lp_parm_string(global_loadparm, NULL, "torture", "host"), "IPC$", NULL, smb_creds, NULL); if (!NT_STATUS_IS_OK(status)) { d_printf("smbcli_full_connection failed: %s\n", @@ -1243,7 +1244,7 @@ static BOOL test_join3(TALLOC_CTX *mem_ctx, goto done; } - cli_credentials_set_conf(wks_creds); + cli_credentials_set_conf(wks_creds, global_loadparm); cli_credentials_set_secure_channel_type(wks_creds, SEC_CHAN_WKSTA); cli_credentials_set_username(wks_creds, wks_name, CRED_SPECIFIED); cli_credentials_set_workstation(wks_creds, wks_name, CRED_SPECIFIED); @@ -1272,7 +1273,7 @@ static BOOL test_join3(TALLOC_CTX *mem_ctx, talloc_free(cli); - ret = True; + ret = true; done: return ret; @@ -1283,10 +1284,10 @@ static BOOL test_join3(TALLOC_CTX *mem_ctx, * session key in the setpassword routine. Test the join by doing the auth2. */ -BOOL torture_samba3_sessionkey(struct torture_context *torture) +bool torture_samba3_sessionkey(struct torture_context *torture) { TALLOC_CTX *mem_ctx; - BOOL ret = False; + bool ret = false; struct cli_credentials *anon_creds; const char *wks_name; @@ -1296,7 +1297,7 @@ BOOL torture_samba3_sessionkey(struct torture_context *torture) if (mem_ctx == NULL) { d_printf("talloc_init failed\n"); - return False; + return false; } if (!(anon_creds = create_anon_creds(mem_ctx))) { @@ -1304,56 +1305,56 @@ BOOL torture_samba3_sessionkey(struct torture_context *torture) goto done; } - ret = True; + ret = true; - if (!torture_setting_bool(torture, "samba3", False)) { + if (!torture_setting_bool(torture, "samba3", false)) { /* Samba3 in the build farm right now does this happily. Need * to fix :-) */ - if (test_join3(mem_ctx, False, anon_creds, NULL, wks_name)) { + if (test_join3(mem_ctx, false, anon_creds, NULL, wks_name)) { d_printf("join using anonymous bind on an anonymous smb " "connection succeeded -- HUH??\n"); - ret = False; + ret = false; } } - if (!test_join3(mem_ctx, False, anon_creds, cmdline_credentials, + if (!test_join3(mem_ctx, false, anon_creds, cmdline_credentials, wks_name)) { d_printf("join using ntlmssp bind on an anonymous smb " "connection failed\n"); - ret = False; + ret = false; } - if (!test_join3(mem_ctx, False, cmdline_credentials, NULL, wks_name)) { + if (!test_join3(mem_ctx, false, cmdline_credentials, NULL, wks_name)) { d_printf("join using anonymous bind on an authenticated smb " "connection failed\n"); - ret = False; + ret = false; } - if (!test_join3(mem_ctx, False, cmdline_credentials, + if (!test_join3(mem_ctx, false, cmdline_credentials, cmdline_credentials, wks_name)) { d_printf("join using ntlmssp bind on an authenticated smb " "connection failed\n"); - ret = False; + ret = false; } /* * The following two are tests for setuserinfolevel 25 */ - if (!test_join3(mem_ctx, True, anon_creds, cmdline_credentials, + if (!test_join3(mem_ctx, true, anon_creds, cmdline_credentials, wks_name)) { d_printf("join using ntlmssp bind on an anonymous smb " "connection failed\n"); - ret = False; + ret = false; } - if (!test_join3(mem_ctx, True, cmdline_credentials, NULL, wks_name)) { + if (!test_join3(mem_ctx, true, cmdline_credentials, NULL, wks_name)) { d_printf("join using anonymous bind on an authenticated smb " "connection failed\n"); - ret = False; + ret = false; } done: @@ -1546,7 +1547,7 @@ NTSTATUS secondary_tcon(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - if (!(result = smbcli_tree_init(session, mem_ctx, False))) { + if (!(result = smbcli_tree_init(session, mem_ctx, false))) { talloc_free(tmp_ctx); return NT_STATUS_NO_MEMORY; } @@ -1576,12 +1577,12 @@ NTSTATUS secondary_tcon(TALLOC_CTX *mem_ctx, * Test the getusername behaviour */ -BOOL torture_samba3_rpc_getusername(struct torture_context *torture) +bool torture_samba3_rpc_getusername(struct torture_context *torture) { NTSTATUS status; struct smbcli_state *cli; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct dom_sid *user_sid; struct dom_sid *created_sid; struct cli_credentials *anon_creds; @@ -1589,7 +1590,7 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) char *domain_name; if (!(mem_ctx = talloc_new(torture))) { - return False; + return false; } status = smbcli_full_connection( @@ -1598,21 +1599,21 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) smbcli_full_connection failed: %s\n", __location__, nt_errstr(status)); - ret = False; + ret = false; goto done; } if (!(user_sid = whoami(mem_ctx, cli->tree))) { d_printf("(%s) whoami on auth'ed connection failed\n", __location__); - ret = False; + ret = false; } talloc_free(cli); if (!(anon_creds = create_anon_creds(mem_ctx))) { d_printf("(%s) create_anon_creds failed\n", __location__); - ret = False; + ret = false; goto done; } @@ -1622,14 +1623,14 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) anon smbcli_full_connection failed: %s\n", __location__, nt_errstr(status)); - ret = False; + ret = false; goto done; } if (!(user_sid = whoami(mem_ctx, cli->tree))) { d_printf("(%s) whoami on anon connection failed\n", __location__); - ret = False; + ret = false; goto done; } @@ -1638,16 +1639,16 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) d_printf("(%s) Anon lsa_GetUserName returned %s, expected " "S-1-5-7", __location__, dom_sid_string(mem_ctx, user_sid)); - ret = False; + ret = false; } if (!(user_creds = cli_credentials_init(mem_ctx))) { d_printf("(%s) cli_credentials_init failed\n", __location__); - ret = False; + ret = false; goto done; } - cli_credentials_set_conf(user_creds); + cli_credentials_set_conf(user_creds, global_loadparm); cli_credentials_set_username(user_creds, "torture_username", CRED_SPECIFIED); cli_credentials_set_password(user_creds, @@ -1659,7 +1660,7 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) cli_credentials_get_password(user_creds), &domain_name, &created_sid)) { d_printf("(%s) create_user failed\n", __location__); - ret = False; + ret = false; goto done; } @@ -1671,7 +1672,7 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) struct smb_composite_sesssetup setup; struct smbcli_tree *tree; - session2 = smbcli_session_init(cli->transport, mem_ctx, False); + session2 = smbcli_session_init(cli->transport, mem_ctx, false); if (session2 == NULL) { d_printf("(%s) smbcli_session_init failed\n", __location__); @@ -1687,7 +1688,7 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) session setup with new user failed: " "%s\n", __location__, nt_errstr(status)); - ret = False; + ret = false; goto done; } session2->vuid = setup.out.vuid; @@ -1696,14 +1697,14 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) "IPC$", &tree))) { d_printf("(%s) secondary_tcon failed\n", __location__); - ret = False; + ret = false; goto done; } if (!(user_sid = whoami(mem_ctx, tree))) { d_printf("(%s) whoami on user connection failed\n", __location__); - ret = False; + ret = false; goto delete; } @@ -1715,14 +1716,14 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) dom_sid_string(mem_ctx, user_sid)); if (!dom_sid_equal(created_sid, user_sid)) { - ret = False; + ret = false; } delete: if (!delete_user(cli, cmdline_credentials, cli_credentials_get_username(user_creds))) { d_printf("(%s) delete_user failed\n", __location__); - ret = False; + ret = false; } done: @@ -1730,14 +1731,14 @@ BOOL torture_samba3_rpc_getusername(struct torture_context *torture) return ret; } -static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *sharename) { NTSTATUS status; struct srvsvc_NetShareGetInfo r; uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007, 1501 }; int i; - BOOL ret = True; + bool ret = true; r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); @@ -1756,14 +1757,14 @@ static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("NetShareGetInfo level %u on share '%s' failed" " - %s\n", r.in.level, r.in.share_name, nt_errstr(status)); - ret = False; + ret = false; continue; } if (!W_ERROR_IS_OK(r.out.result)) { printf("NetShareGetInfo level %u on share '%s' failed " "- %s\n", r.in.level, r.in.share_name, win_errstr(r.out.result)); - ret = False; + ret = false; continue; } } @@ -1771,7 +1772,7 @@ static BOOL test_NetShareGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char **one_sharename) { NTSTATUS status; @@ -1779,7 +1780,7 @@ static BOOL test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct srvsvc_NetShareCtr0 c0; uint32_t levels[] = { 0, 1, 2, 501, 502, 1004, 1005, 1006, 1007 }; int i; - BOOL ret = True; + bool ret = true; r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); r.in.ctr.ctr0 = &c0; @@ -1798,7 +1799,7 @@ static BOOL test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("NetShareEnum level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; continue; } if (!W_ERROR_IS_OK(r.out.result)) { @@ -1817,24 +1818,24 @@ static BOOL test_NetShareEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -BOOL torture_samba3_rpc_srvsvc(struct torture_context *torture) +bool torture_samba3_rpc_srvsvc(struct torture_context *torture) { struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; const char *sharename = NULL; struct smbcli_state *cli; NTSTATUS status; if (!(mem_ctx = talloc_new(torture))) { - return False; + return false; } if (!(torture_open_connection_share( mem_ctx, &cli, torture_setting_string(torture, "host", NULL), "IPC$", NULL))) { talloc_free(mem_ctx); - return False; + return false; } status = pipe_bind_smb(mem_ctx, cli->tree, "\\pipe\\srvsvc", @@ -1842,7 +1843,7 @@ BOOL torture_samba3_rpc_srvsvc(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) could not bind to srvsvc pipe: %s\n", __location__, nt_errstr(status)); - ret = False; + ret = false; goto done; } @@ -1966,7 +1967,7 @@ static NTSTATUS set_sharesec(TALLOC_CTX *mem_ctx, return status; } -BOOL try_tcon(TALLOC_CTX *mem_ctx, +bool try_tcon(TALLOC_CTX *mem_ctx, struct security_descriptor *orig_sd, struct smbcli_session *session, const char *sharename, const struct dom_sid *user_sid, @@ -1979,18 +1980,18 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx, uint32_t rid; struct security_descriptor *sd; NTSTATUS status; - BOOL ret = True; + bool ret = true; if (!(tmp_ctx = talloc_new(mem_ctx))) { d_printf("talloc_new failed\n"); - return False; + return false; } status = secondary_tcon(tmp_ctx, session, sharename, &rmdir_tree); if (!NT_STATUS_IS_OK(status)) { d_printf("first tcon to delete dir failed\n"); talloc_free(tmp_ctx); - return False; + return false; } smbcli_rmdir(rmdir_tree, "sharesec_testdir"); @@ -1999,7 +2000,7 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx, &domain_sid, &rid))) { d_printf("dom_sid_split_rid failed\n"); talloc_free(tmp_ctx); - return False; + return false; } sd = security_descriptor_create( @@ -2011,7 +2012,7 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx, if (sd == NULL) { d_printf("security_descriptor_create failed\n"); talloc_free(tmp_ctx); - return False; + return false; } status = set_sharesec(mem_ctx, session, sharename, sd); @@ -2019,14 +2020,14 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx, d_printf("custom set_sharesec failed: %s\n", nt_errstr(status)); talloc_free(tmp_ctx); - return False; + return false; } status = secondary_tcon(tmp_ctx, session, sharename, &tree); if (!NT_STATUS_EQUAL(status, expected_tcon)) { d_printf("Expected %s, got %s\n", nt_errstr(expected_tcon), nt_errstr(status)); - ret = False; + ret = false; goto done; } @@ -2039,7 +2040,7 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(status, expected_mkdir)) { d_printf("(%s) Expected %s, got %s\n", __location__, nt_errstr(expected_mkdir), nt_errstr(status)); - ret = False; + ret = false; } done: @@ -2050,23 +2051,23 @@ BOOL try_tcon(TALLOC_CTX *mem_ctx, d_printf("custom set_sharesec failed: %s\n", nt_errstr(status)); talloc_free(tmp_ctx); - return False; + return false; } talloc_free(tmp_ctx); return ret; } -BOOL torture_samba3_rpc_sharesec(struct torture_context *torture) +bool torture_samba3_rpc_sharesec(struct torture_context *torture) { TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct smbcli_state *cli; struct security_descriptor *sd; struct dom_sid *user_sid; if (!(mem_ctx = talloc_new(torture))) { - return False; + return false; } if (!(torture_open_connection_share( @@ -2074,13 +2075,13 @@ BOOL torture_samba3_rpc_sharesec(struct torture_context *torture) "IPC$", NULL))) { d_printf("IPC$ connection failed\n"); talloc_free(mem_ctx); - return False; + return false; } if (!(user_sid = whoami(mem_ctx, cli->tree))) { d_printf("whoami failed\n"); talloc_free(mem_ctx); - return False; + return false; } sd = get_sharesec(mem_ctx, cli->session, torture_setting_string(torture, @@ -2103,10 +2104,10 @@ BOOL torture_samba3_rpc_sharesec(struct torture_context *torture) return ret; } -BOOL torture_samba3_rpc_lsa(struct torture_context *torture) +bool torture_samba3_rpc_lsa(struct torture_context *torture) { TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct smbcli_state *cli; struct dcerpc_pipe *p; struct policy_handle lsa_handle; @@ -2114,7 +2115,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture) struct dom_sid *domain_sid; if (!(mem_ctx = talloc_new(torture))) { - return False; + return false; } if (!(torture_open_connection_share( @@ -2122,7 +2123,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture) "IPC$", NULL))) { d_printf("IPC$ connection failed\n"); talloc_free(mem_ctx); - return False; + return false; } status = pipe_bind_smb(mem_ctx, cli->tree, "\\lsarpc", @@ -2131,7 +2132,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture) d_printf("(%s) pipe_bind_smb failed: %s\n", __location__, nt_errstr(status)); talloc_free(mem_ctx); - return False; + return false; } { @@ -2148,7 +2149,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture) d_printf("(%s) dcerpc_lsa_OpenPolicy2 failed: %s\n", __location__, nt_errstr(status)); talloc_free(mem_ctx); - return False; + return false; } } @@ -2170,7 +2171,7 @@ BOOL torture_samba3_rpc_lsa(struct torture_context *torture) "failed: %s\n", __location__, levels[i], nt_errstr(status)); talloc_free(mem_ctx); - return False; + return false; } if (levels[i] == 5) { domain_sid = r.out.info->account_domain.sid; @@ -2265,7 +2266,7 @@ static NTSTATUS find_printers(TALLOC_CTX *ctx, struct smbcli_tree *tree, return NT_STATUS_OK; } -static BOOL enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe, +static bool enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe, const char *servername, int level, int *num_printers) { struct spoolss_EnumPrinters r; @@ -2282,20 +2283,20 @@ static BOOL enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe, if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) dcerpc_spoolss_EnumPrinters failed: %s\n", __location__, nt_errstr(status)); - return False; + return false; } if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { d_printf("(%s) EnumPrinters unexpected return code %s, should " "be WERR_INSUFFICIENT_BUFFER\n", __location__, win_errstr(r.out.result)); - return False; + return false; } blob = data_blob_talloc_zero(mem_ctx, r.out.needed); if (blob.data == NULL) { d_printf("(%s) data_blob_talloc failed\n", __location__); - return False; + return false; } r.in.buffer = &blob; @@ -2306,12 +2307,12 @@ static BOOL enumprinters(TALLOC_CTX *mem_ctx, struct dcerpc_pipe *pipe, d_printf("(%s) dcerpc_spoolss_EnumPrinters failed: %s, " "%s\n", __location__, nt_errstr(status), win_errstr(r.out.result)); - return False; + return false; } *num_printers = r.out.count; - return True; + return true; } static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe, @@ -2378,10 +2379,10 @@ static NTSTATUS getprinterinfo(TALLOC_CTX *ctx, struct dcerpc_pipe *pipe, return NT_STATUS_OK; } -BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) +bool torture_samba3_rpc_spoolss(struct torture_context *torture) { TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct smbcli_state *cli; struct dcerpc_pipe *p; NTSTATUS status; @@ -2392,7 +2393,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) char *servername; if (!(mem_ctx = talloc_new(torture))) { - return False; + return false; } if (!(torture_open_connection_share( @@ -2400,7 +2401,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) "IPC$", NULL))) { d_printf("IPC$ connection failed\n"); talloc_free(mem_ctx); - return False; + return false; } status = get_servername(mem_ctx, cli->tree, &servername); @@ -2408,19 +2409,19 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) d_fprintf(stderr, "(%s) get_servername returned %s\n", __location__, nt_errstr(status)); talloc_free(mem_ctx); - return False; + return false; } if (!NT_STATUS_IS_OK(find_printers(mem_ctx, cli->tree, &printers, &num_printers))) { talloc_free(mem_ctx); - return False; + return false; } if (num_printers == 0) { d_printf("Did not find printers\n"); talloc_free(mem_ctx); - return True; + return true; } status = pipe_bind_smb(mem_ctx, cli->tree, "\\spoolss", @@ -2429,12 +2430,12 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) d_printf("(%s) pipe_bind_smb failed: %s\n", __location__, nt_errstr(status)); talloc_free(mem_ctx); - return False; + return false; } ZERO_STRUCT(userlevel1); userlevel1.client = talloc_asprintf( - mem_ctx, "\\\\%s", lp_netbios_name()); + mem_ctx, "\\\\%s", lp_netbios_name(global_loadparm)); userlevel1.user = cli_credentials_get_username(cmdline_credentials); userlevel1.build = 2600; userlevel1.major = 3; @@ -2459,7 +2460,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) "%s, %s\n", __location__, nt_errstr(status), win_errstr(r.out.result)); talloc_free(mem_ctx); - return False; + return false; } } @@ -2475,7 +2476,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) "%s, %s\n", __location__, nt_errstr(status), win_errstr(r.out.result)); talloc_free(mem_ctx); - return False; + return false; } } @@ -2497,7 +2498,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) "%s, %s\n", __location__, nt_errstr(status), win_errstr(r.out.result)); talloc_free(mem_ctx); - return False; + return false; } } @@ -2510,7 +2511,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) getprinterinfo %d failed: %s\n", __location__, i, nt_errstr(status)); - ret = False; + ret = false; } } } @@ -2526,7 +2527,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) d_printf("(%s) dcerpc_spoolss_ClosePrinter failed: " "%s\n", __location__, nt_errstr(status)); talloc_free(mem_ctx); - return False; + return false; } } @@ -2536,14 +2537,14 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) &num_enumerated)) { d_printf("(%s) enumprinters failed\n", __location__); talloc_free(mem_ctx); - return False; + return false; } if (num_printers != num_enumerated) { d_printf("(%s) netshareenum gave %d printers, " "enumprinters lvl 1 gave %d\n", __location__, num_printers, num_enumerated); talloc_free(mem_ctx); - return False; + return false; } } @@ -2553,14 +2554,14 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) &num_enumerated)) { d_printf("(%s) enumprinters failed\n", __location__); talloc_free(mem_ctx); - return False; + return false; } if (num_printers != num_enumerated) { d_printf("(%s) netshareenum gave %d printers, " "enumprinters lvl 2 gave %d\n", __location__, num_printers, num_enumerated); talloc_free(mem_ctx); - return False; + return false; } } @@ -2569,7 +2570,7 @@ BOOL torture_samba3_rpc_spoolss(struct torture_context *torture) return ret; } -BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture) +bool torture_samba3_rpc_wkssvc(struct torture_context *torture) { TALLOC_CTX *mem_ctx; struct smbcli_state *cli; @@ -2578,7 +2579,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture) char *servername; if (!(mem_ctx = talloc_new(torture))) { - return False; + return false; } if (!(torture_open_connection_share( @@ -2586,7 +2587,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture) "IPC$", NULL))) { d_printf("IPC$ connection failed\n"); talloc_free(mem_ctx); - return False; + return false; } status = get_servername(mem_ctx, cli->tree, &servername); @@ -2594,7 +2595,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture) d_fprintf(stderr, "(%s) get_servername returned %s\n", __location__, nt_errstr(status)); talloc_free(mem_ctx); - return False; + return false; } status = pipe_bind_smb(mem_ctx, cli->tree, "\\wkssvc", @@ -2603,7 +2604,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture) d_printf("(%s) pipe_bind_smb failed: %s\n", __location__, nt_errstr(status)); talloc_free(mem_ctx); - return False; + return false; } { @@ -2622,7 +2623,7 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture) "%s, %s\n", __location__, nt_errstr(status), win_errstr(r.out.result)); talloc_free(mem_ctx); - return False; + return false; } if (strcmp(servername, @@ -2632,12 +2633,12 @@ BOOL torture_samba3_rpc_wkssvc(struct torture_context *torture) __location__, servername, r.out.info->info100->server_name); talloc_free(mem_ctx); - return False; + return false; } } talloc_free(mem_ctx); - return True; + return true; } static NTSTATUS winreg_close(struct dcerpc_pipe *p, @@ -2766,14 +2767,14 @@ static NTSTATUS enumkeys(struct dcerpc_pipe *p, struct policy_handle *handle, talloc_free(tmp_ctx); r.in.enum_index += 1; - } while(True); + } while(true); return NT_STATUS_OK; } typedef NTSTATUS (*winreg_open_fn)(struct dcerpc_pipe *, TALLOC_CTX *, void *); -static BOOL test_Open3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_Open3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *name, winreg_open_fn open_fn) { struct policy_handle handle; @@ -2788,7 +2789,7 @@ static BOOL test_Open3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status) || !W_ERROR_IS_OK(r.out.result)) { d_printf("(%s) %s failed: %s, %s\n", __location__, name, nt_errstr(status), win_errstr(r.out.result)); - return False; + return false; } enumkeys(p, &handle, mem_ctx, 4); @@ -2797,18 +2798,18 @@ static BOOL test_Open3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { d_printf("(%s) dcerpc_CloseKey failed: %s\n", __location__, nt_errstr(status)); - return False; + return false; } - return True; + return true; } -BOOL torture_samba3_rpc_winreg(struct torture_context *torture) +bool torture_samba3_rpc_winreg(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct { const char *name; winreg_open_fn fn; @@ -2828,7 +2829,7 @@ BOOL torture_samba3_rpc_winreg(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { talloc_free(mem_ctx); - return False; + return false; } #if 1 @@ -2836,7 +2837,7 @@ BOOL torture_samba3_rpc_winreg(struct torture_context *torture) #else for (i = 0; i < ARRAY_SIZE(open_fns); i++) { if (!test_Open3(p, mem_ctx, open_fns[i].name, open_fns[i].fn)) - ret = False; + ret = false; } #endif diff --git a/source4/torture/rpc/samlogon.c b/source4/torture/rpc/samlogon.c index da74067336..aa0f6de788 100644 --- a/source4/torture/rpc/samlogon.c +++ b/source4/torture/rpc/samlogon.c @@ -31,6 +31,7 @@ #include "torture/rpc/rpc.h" #include "auth/gensec/schannel_proto.h" #include "libcli/auth/libcli_auth.h" +#include "param/param.h" #define TEST_MACHINE_NAME "samlogontest" #define TEST_USER_NAME "samlogontestuser" @@ -61,7 +62,7 @@ struct samlogon_state { struct netr_Authenticator auth, auth2; struct creds_CredentialState *creds; NTSTATUS expected_error; - BOOL old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */ + bool old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */ DATA_BLOB chall; }; @@ -262,10 +263,10 @@ static NTSTATUS check_samlogon(struct samlogon_state *samlogon_state, * Test the normal 'LM and NTLM' combination */ -static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm_break break_which, char **error_string) +static bool test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm_break break_which, char **error_string) { - BOOL pass = True; - BOOL lm_good; + bool pass = true; + bool lm_good; NTSTATUS nt_status; DATA_BLOB lm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24); DATA_BLOB nt_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24); @@ -306,11 +307,11 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) { /* for 'long' passwords, the LM password is invalid */ if (break_which == NO_NT && !lm_good) { - return True; + return true; } /* for 'old' passwords, we allow the server to be OK or wrong password */ if (samlogon_state->old_password) { - return True; + return true; } return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH)); } else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) { @@ -318,16 +319,16 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm } else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) { SAFE_FREE(*error_string); asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status)); - return False; + return false; } else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) { - return True; + return true; } else if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return false; } if (break_which == NO_NT && !lm_good) { *error_string = strdup("LM password is 'long' (> 14 chars and therefore invalid) but login did not fail!"); - return False; + return false; } if (memcmp(lm_hash, lm_key, @@ -337,7 +338,7 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm dump_data(1, lm_key, 8); d_printf("expected:\n"); dump_data(1, lm_hash, 8); - pass = False; + pass = false; } switch (break_which) { @@ -353,7 +354,7 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm dump_data(1, user_session_key, sizeof(user_session_key)); d_printf("expected:\n"); dump_data(1, lm_key_expected, sizeof(lm_key_expected)); - pass = False; + pass = false; } break; } @@ -365,7 +366,7 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm dump_data(1, user_session_key, 16); d_printf("expected:\n"); dump_data(1, session_key.data, session_key.length); - pass = False; + pass = false; } } return pass; @@ -375,7 +376,7 @@ static BOOL test_lm_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm * Test LM authentication, no NT response supplied */ -static BOOL test_lm(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lm(struct samlogon_state *samlogon_state, char **error_string) { return test_lm_ntlm_broken(samlogon_state, NO_NT, error_string); @@ -385,7 +386,7 @@ static BOOL test_lm(struct samlogon_state *samlogon_state, char **error_string) * Test the NTLM response only, no LM. */ -static BOOL test_ntlm(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlm(struct samlogon_state *samlogon_state, char **error_string) { return test_lm_ntlm_broken(samlogon_state, NO_LM, error_string); } @@ -394,10 +395,10 @@ static BOOL test_ntlm(struct samlogon_state *samlogon_state, char **error_string * Test the NTLM response only, but in the LM field. */ -static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_string) { - BOOL lm_good; - BOOL pass = True; + bool lm_good; + bool pass = true; NTSTATUS nt_status; DATA_BLOB nt_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24); DATA_BLOB session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16); @@ -433,17 +434,17 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_ if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) { /* for 'old' passwords, we allow the server to be OK or wrong password */ if (samlogon_state->old_password) { - return True; + return true; } - return False; + return false; } else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) { SAFE_FREE(*error_string); asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status)); - return False; + return false; } else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) { - return True; + return true; } else if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return false; } if (lm_good) { @@ -454,7 +455,7 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_ dump_data(1, lm_key, 8); d_printf("expected:\n"); dump_data(1, lm_hash, 8); - pass = False; + pass = false; } #if 0 } else { @@ -465,7 +466,7 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_ dump_data(1, lm_key, 8); d_printf("expected:\n"); dump_data(1, session_key.data, 8); - pass = False; + pass = false; } #endif } @@ -480,7 +481,7 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_ dump_data(1, user_session_key, sizeof(user_session_key)); d_printf("expected:\n"); dump_data(1, lm_key_expected, sizeof(lm_key_expected)); - pass = False; + pass = false; } } return pass; @@ -490,10 +491,10 @@ static BOOL test_ntlm_in_lm(struct samlogon_state *samlogon_state, char **error_ * Test the NTLM response only, but in the both the NT and LM fields. */ -static BOOL test_ntlm_in_both(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlm_in_both(struct samlogon_state *samlogon_state, char **error_string) { - BOOL pass = True; - BOOL lm_good; + bool pass = true; + bool lm_good; NTSTATUS nt_status; DATA_BLOB nt_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24); DATA_BLOB session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16); @@ -530,21 +531,21 @@ static BOOL test_ntlm_in_both(struct samlogon_state *samlogon_state, char **erro if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) { /* for 'old' passwords, we allow the server to be OK or wrong password */ if (samlogon_state->old_password) { - return True; + return true; } - return False; + return false; } else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) { SAFE_FREE(*error_string); asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status)); - return False; + return false; } else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) { - return True; + return true; } else if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return false; } if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return false; } if (memcmp(lm_hash, lm_key, @@ -554,7 +555,7 @@ static BOOL test_ntlm_in_both(struct samlogon_state *samlogon_state, char **erro dump_data(1, lm_key, 8); d_printf("expected:\n"); dump_data(1, lm_hash, 8); - pass = False; + pass = false; } if (memcmp(session_key.data, user_session_key, sizeof(user_session_key)) != 0) { @@ -563,7 +564,7 @@ static BOOL test_ntlm_in_both(struct samlogon_state *samlogon_state, char **erro dump_data(1, user_session_key, 16); d_printf("expected:\n"); dump_data(1, session_key.data, session_key.length); - pass = False; + pass = false; } @@ -579,18 +580,18 @@ enum ntlmv2_domain { NO_DOMAIN }; -static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, +static bool test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, enum ntlm_break break_which, enum ntlmv2_domain ntlmv2_domain, char **error_string) { - BOOL pass = True; + bool pass = true; NTSTATUS nt_status; DATA_BLOB ntlmv2_response = data_blob(NULL, 0); DATA_BLOB lmv2_response = data_blob(NULL, 0); DATA_BLOB lmv2_session_key = data_blob(NULL, 0); DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0); - DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, TEST_MACHINE_NAME, lp_workgroup()); + DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, TEST_MACHINE_NAME, lp_workgroup(global_loadparm)); uint8_t lm_session_key[8]; uint8_t user_session_key[16]; @@ -607,7 +608,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, &lmv2_response, &ntlmv2_response, &lmv2_session_key, &ntlmv2_session_key)) { data_blob_free(&names_blob); - return False; + return false; } break; case NO_DOMAIN: @@ -618,7 +619,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, &lmv2_response, &ntlmv2_response, &lmv2_session_key, &ntlmv2_session_key)) { data_blob_free(&names_blob); - return False; + return false; } break; } @@ -641,7 +642,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) { /* for 'old' passwords, we allow the server to be OK or wrong password */ if (samlogon_state->old_password) { - return True; + return true; } return break_which == BREAK_BOTH; } else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) { @@ -649,11 +650,11 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, } else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) { SAFE_FREE(*error_string); asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status)); - return False; + return false; } else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) { - return True; + return true; } else if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return false; } @@ -666,7 +667,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, dump_data(1, user_session_key, 16); d_printf("expected:\n"); dump_data(1, lmv2_session_key.data, ntlmv2_session_key.length); - pass = False; + pass = false; } if (memcmp(lmv2_session_key.data, lm_session_key, sizeof(lm_session_key)) != 0) { @@ -675,7 +676,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, dump_data(1, lm_session_key, 8); d_printf("expected:\n"); dump_data(1, lmv2_session_key.data, 8); - pass = False; + pass = false; } break; default: @@ -688,7 +689,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, dump_data(1, user_session_key, 16); d_printf("expected:\n"); dump_data(1, ntlmv2_session_key.data, ntlmv2_session_key.length); - pass = False; + pass = false; } else { d_printf("USER (NTLMv2) Session Key does not match expectations!\n"); @@ -696,7 +697,7 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, dump_data(1, user_session_key, 16); d_printf("expected:\n"); dump_data(1, ntlmv2_session_key.data, ntlmv2_session_key.length); - pass = False; + pass = false; } } if (memcmp(ntlmv2_session_key.data, lm_session_key, @@ -708,14 +709,14 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, dump_data(1, lm_session_key, 8); d_printf("expected:\n"); dump_data(1, ntlmv2_session_key.data, 8); - pass = False; + pass = false; } else { d_printf("LM (NTLMv2) Session Key does not match expectations!\n"); d_printf("lm_session_key:\n"); dump_data(1, lm_session_key, 8); d_printf("expected:\n"); dump_data(1, ntlmv2_session_key.data, 8); - pass = False; + pass = false; } } } @@ -727,23 +728,23 @@ static BOOL test_lmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, * Test the NTLM and LMv2 responses */ -static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, +static bool test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, enum ntlm_break break_which, enum ntlmv2_domain ntlmv2_domain, char **error_string) { - BOOL pass = True; + bool pass = true; NTSTATUS nt_status; DATA_BLOB ntlmv2_response = data_blob(NULL, 0); DATA_BLOB lmv2_response = data_blob(NULL, 0); DATA_BLOB lmv2_session_key = data_blob(NULL, 0); DATA_BLOB ntlmv2_session_key = data_blob(NULL, 0); - DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, lp_netbios_name(), lp_workgroup()); + DATA_BLOB names_blob = NTLMv2_generate_names_blob(samlogon_state->mem_ctx, lp_netbios_name(global_loadparm), lp_workgroup(global_loadparm)); DATA_BLOB ntlm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24); DATA_BLOB ntlm_session_key = data_blob_talloc(samlogon_state->mem_ctx, NULL, 16); - BOOL lm_good; + bool lm_good; uint8_t lm_hash[16]; uint8_t lm_session_key[8]; uint8_t user_session_key[16]; @@ -773,7 +774,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, &lmv2_response, &ntlmv2_response, &lmv2_session_key, &ntlmv2_session_key)) { data_blob_free(&names_blob); - return False; + return false; } break; case NO_DOMAIN: @@ -785,7 +786,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, &lmv2_response, &ntlmv2_response, &lmv2_session_key, &ntlmv2_session_key)) { data_blob_free(&names_blob); - return False; + return false; } break; } @@ -809,7 +810,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) { /* for 'old' passwords, we allow the server to be OK or wrong password */ if (samlogon_state->old_password) { - return True; + return true; } return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH)); } else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) { @@ -817,11 +818,11 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, } else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) { SAFE_FREE(*error_string); asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status)); - return False; + return false; } else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) { - return True; + return true; } else if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return false; } switch (break_which) { @@ -833,7 +834,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, dump_data(1, user_session_key, 16); d_printf("expected:\n"); dump_data(1, lmv2_session_key.data, ntlmv2_session_key.length); - pass = False; + pass = false; } if (memcmp(lmv2_session_key.data, lm_session_key, sizeof(lm_session_key)) != 0) { @@ -842,7 +843,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, dump_data(1, lm_session_key, 8); d_printf("expected:\n"); dump_data(1, lmv2_session_key.data, 8); - pass = False; + pass = false; } break; case BREAK_LM: @@ -853,7 +854,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, dump_data(1, user_session_key, 16); d_printf("expected:\n"); dump_data(1, ntlm_session_key.data, ntlm_session_key.length); - pass = False; + pass = false; } if (lm_good) { if (memcmp(lm_hash, lm_session_key, @@ -863,7 +864,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, dump_data(1, lm_session_key, 8); d_printf("expected:\n"); dump_data(1, lm_hash, 8); - pass = False; + pass = false; } } else { static const uint8_t zeros[8]; @@ -874,7 +875,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, dump_data(1, lm_session_key, 8); d_printf("expected:\n"); dump_data(1, zeros, 8); - pass = False; + pass = false; } } break; @@ -886,7 +887,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, dump_data(1, user_session_key, 16); d_printf("expected:\n"); dump_data(1, ntlm_session_key.data, ntlm_session_key.length); - pass = False; + pass = false; } if (memcmp(ntlm_session_key.data, lm_session_key, sizeof(lm_session_key)) != 0) { @@ -895,7 +896,7 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, dump_data(1, lm_session_key, 8); d_printf("expected:\n"); dump_data(1, ntlm_session_key.data, 8); - pass = False; + pass = false; } } @@ -906,13 +907,13 @@ static BOOL test_lmv2_ntlm_broken(struct samlogon_state *samlogon_state, * Test the NTLMv2 and LMv2 responses */ -static BOOL test_lmv2_ntlmv2(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2_ntlmv2(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_NONE, UPPER_DOMAIN, error_string); } #if 0 -static BOOL test_lmv2_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_NONE, NO_DOMAIN, error_string); } @@ -922,12 +923,12 @@ static BOOL test_lmv2_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char * Test the LMv2 response only */ -static BOOL test_lmv2(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, NO_NT, UPPER_DOMAIN, error_string); } -static BOOL test_lmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, NO_NT, NO_DOMAIN, error_string); } @@ -936,93 +937,93 @@ static BOOL test_lmv2_no_dom(struct samlogon_state *samlogon_state, char **error * Test the NTLMv2 response only */ -static BOOL test_ntlmv2(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlmv2(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, NO_LM, UPPER_DOMAIN, error_string); } -static BOOL test_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlmv2_no_dom(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, NO_LM, NO_DOMAIN, error_string); } -static BOOL test_lm_ntlm(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lm_ntlm(struct samlogon_state *samlogon_state, char **error_string) { return test_lm_ntlm_broken(samlogon_state, BREAK_NONE, error_string); } -static BOOL test_ntlm_lm_broken(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlm_lm_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_lm_ntlm_broken(samlogon_state, BREAK_LM, error_string); } -static BOOL test_ntlm_ntlm_broken(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlm_ntlm_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_lm_ntlm_broken(samlogon_state, BREAK_NT, error_string); } -static BOOL test_lm_ntlm_both_broken(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lm_ntlm_both_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_lm_ntlm_broken(samlogon_state, BREAK_BOTH, error_string); } -static BOOL test_ntlmv2_lmv2_broken(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlmv2_lmv2_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_LM, UPPER_DOMAIN, error_string); } -static BOOL test_ntlmv2_lmv2_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlmv2_lmv2_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_LM, NO_DOMAIN, error_string); } -static BOOL test_ntlmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlmv2_ntlmv2_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_NT, UPPER_DOMAIN, error_string); } #if 0 -static BOOL test_ntlmv2_ntlmv2_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlmv2_ntlmv2_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_NT, NO_DOMAIN, error_string); } #endif -static BOOL test_ntlmv2_both_broken(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlmv2_both_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_BOTH, UPPER_DOMAIN, error_string); } -static BOOL test_ntlmv2_both_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlmv2_both_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlmv2_broken(samlogon_state, BREAK_BOTH, NO_DOMAIN, error_string); } -static BOOL test_lmv2_ntlm_both_broken(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2_ntlm_both_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlm_broken(samlogon_state, BREAK_BOTH, UPPER_DOMAIN, error_string); } -static BOOL test_lmv2_ntlm_both_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2_ntlm_both_broken_no_dom(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlm_broken(samlogon_state, BREAK_BOTH, NO_DOMAIN, error_string); } -static BOOL test_lmv2_ntlm_break_ntlm(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2_ntlm_break_ntlm(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlm_broken(samlogon_state, BREAK_NT, UPPER_DOMAIN, error_string); } -static BOOL test_lmv2_ntlm_break_ntlm_no_dom(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2_ntlm_break_ntlm_no_dom(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlm_broken(samlogon_state, BREAK_NT, NO_DOMAIN, error_string); } -static BOOL test_lmv2_ntlm_break_lm(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2_ntlm_break_lm(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlm_broken(samlogon_state, BREAK_LM, UPPER_DOMAIN, error_string); } -static BOOL test_lmv2_ntlm_break_lm_no_dom(struct samlogon_state *samlogon_state, char **error_string) +static bool test_lmv2_ntlm_break_lm_no_dom(struct samlogon_state *samlogon_state, char **error_string) { return test_lmv2_ntlm_broken(samlogon_state, BREAK_LM, NO_DOMAIN, error_string); } @@ -1035,14 +1036,14 @@ static BOOL test_lmv2_ntlm_break_lm_no_dom(struct samlogon_state *samlogon_state * (NETLOGON is the wrong place). */ -static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_string) +static bool test_ntlm2(struct samlogon_state *samlogon_state, char **error_string) { - BOOL pass = True; + bool pass = true; NTSTATUS nt_status; DATA_BLOB lm_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24); DATA_BLOB nt_response = data_blob_talloc(samlogon_state->mem_ctx, NULL, 24); - BOOL lm_good; + bool lm_good; uint8_t lm_key[8]; uint8_t nt_hash[16]; uint8_t lm_hash[16]; @@ -1092,17 +1093,17 @@ static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) { /* for 'old' passwords, we allow the server to be OK or wrong password */ if (samlogon_state->old_password) { - return True; + return true; } - return False; + return false; } else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) { SAFE_FREE(*error_string); asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status)); - return False; + return false; } else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) { - return True; + return true; } else if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return false; } if (lm_good) { @@ -1113,7 +1114,7 @@ static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin dump_data(1, lm_key, 8); d_printf("expected:\n"); dump_data(1, lm_hash, 8); - pass = False; + pass = false; } } else { static const uint8_t zeros[8]; @@ -1124,7 +1125,7 @@ static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin dump_data(1, lm_key, 8); d_printf("expected:\n"); dump_data(1, zeros, 8); - pass = False; + pass = false; } } if (memcmp(nt_key, user_session_key, 16) != 0) { @@ -1133,12 +1134,12 @@ static BOOL test_ntlm2(struct samlogon_state *samlogon_state, char **error_strin dump_data(1, user_session_key, sizeof(user_session_key)); d_printf("expected:\n"); dump_data(1, nt_key, sizeof(nt_key)); - pass = False; + pass = false; } return pass; } -static BOOL test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_break break_which, char **error_string) +static bool test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_break break_which, char **error_string) { NTSTATUS nt_status; DATA_BLOB nt_response = data_blob(NULL, 0); @@ -1152,7 +1153,7 @@ static BOOL test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea uint8_t lm_hash[16]; static const uint8_t zeros[8]; DATA_BLOB chall = data_blob_talloc(samlogon_state->mem_ctx, zeros, sizeof(zeros)); - BOOL lm_good = E_deshash(samlogon_state->password, lm_hash); + bool lm_good = E_deshash(samlogon_state->password, lm_hash); ZERO_STRUCT(user_session_key); @@ -1189,11 +1190,11 @@ static BOOL test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea if (NT_STATUS_EQUAL(NT_STATUS_WRONG_PASSWORD, nt_status)) { /* for 'old' passwords, we allow the server to be OK or wrong password */ if (samlogon_state->old_password) { - return True; + return true; } /* for 'long' passwords, the LM password is invalid */ if (break_which == NO_NT && !lm_good) { - return True; + return true; } return ((break_which == BREAK_NT) || (break_which == BREAK_BOTH)); } else if (NT_STATUS_EQUAL(NT_STATUS_NOT_FOUND, nt_status) && strchr_m(samlogon_state->account_name, '@')) { @@ -1201,42 +1202,42 @@ static BOOL test_plaintext(struct samlogon_state *samlogon_state, enum ntlm_brea } else if (!NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status)) { SAFE_FREE(*error_string); asprintf(error_string, "Expected error: %s, got %s", nt_errstr(samlogon_state->expected_error), nt_errstr(nt_status)); - return False; + return false; } else if (NT_STATUS_EQUAL(samlogon_state->expected_error, nt_status) && !NT_STATUS_IS_OK(nt_status)) { - return True; + return true; } else if (!NT_STATUS_IS_OK(nt_status)) { - return False; + return false; } if (break_which == NO_NT && !lm_good) { *error_string = strdup("LM password is 'long' (> 14 chars and therefore invalid) but login did not fail!"); - return False; + return false; } - return True; + return true; } -static BOOL test_plaintext_none_broken(struct samlogon_state *samlogon_state, +static bool test_plaintext_none_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_plaintext(samlogon_state, BREAK_NONE, error_string); } -static BOOL test_plaintext_lm_broken(struct samlogon_state *samlogon_state, +static bool test_plaintext_lm_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_plaintext(samlogon_state, BREAK_LM, error_string); } -static BOOL test_plaintext_nt_broken(struct samlogon_state *samlogon_state, +static bool test_plaintext_nt_broken(struct samlogon_state *samlogon_state, char **error_string) { return test_plaintext(samlogon_state, BREAK_NT, error_string); } -static BOOL test_plaintext_nt_only(struct samlogon_state *samlogon_state, +static bool test_plaintext_nt_only(struct samlogon_state *samlogon_state, char **error_string) { return test_plaintext(samlogon_state, NO_LM, error_string); } -static BOOL test_plaintext_lm_only(struct samlogon_state *samlogon_state, +static bool test_plaintext_lm_only(struct samlogon_state *samlogon_state, char **error_string) { return test_plaintext(samlogon_state, NO_NT, error_string); } @@ -1260,63 +1261,63 @@ static BOOL test_plaintext_lm_only(struct samlogon_state *samlogon_state, */ static const struct ntlm_tests { - BOOL (*fn)(struct samlogon_state *, char **); + bool (*fn)(struct samlogon_state *, char **); const char *name; - BOOL expect_fail; + bool expect_fail; } test_table[] = { - {test_lmv2_ntlmv2, "NTLMv2 and LMv2", False}, + {test_lmv2_ntlmv2, "NTLMv2 and LMv2", false}, #if 0 - {test_lmv2_ntlmv2_no_dom, "NTLMv2 and LMv2 (no domain)", False}, + {test_lmv2_ntlmv2_no_dom, "NTLMv2 and LMv2 (no domain)", false}, #endif - {test_lm, "LM", False}, - {test_lm_ntlm, "LM and NTLM", False}, - {test_lm_ntlm_both_broken, "LM and NTLM, both broken", False}, - {test_ntlm, "NTLM", False}, - {test_ntlm_in_lm, "NTLM in LM", False}, - {test_ntlm_in_both, "NTLM in both", False}, - {test_ntlmv2, "NTLMv2", False}, - {test_ntlmv2_no_dom, "NTLMv2 (no domain)", False}, - {test_lmv2, "LMv2", False}, - {test_lmv2_no_dom, "LMv2 (no domain)", False}, - {test_ntlmv2_lmv2_broken, "NTLMv2 and LMv2, LMv2 broken", False}, - {test_ntlmv2_lmv2_broken_no_dom, "NTLMv2 and LMv2, LMv2 broken (no domain)", False}, - {test_ntlmv2_ntlmv2_broken, "NTLMv2 and LMv2, NTLMv2 broken", False}, + {test_lm, "LM", false}, + {test_lm_ntlm, "LM and NTLM", false}, + {test_lm_ntlm_both_broken, "LM and NTLM, both broken", false}, + {test_ntlm, "NTLM", false}, + {test_ntlm_in_lm, "NTLM in LM", false}, + {test_ntlm_in_both, "NTLM in both", false}, + {test_ntlmv2, "NTLMv2", false}, + {test_ntlmv2_no_dom, "NTLMv2 (no domain)", false}, + {test_lmv2, "LMv2", false}, + {test_lmv2_no_dom, "LMv2 (no domain)", false}, + {test_ntlmv2_lmv2_broken, "NTLMv2 and LMv2, LMv2 broken", false}, + {test_ntlmv2_lmv2_broken_no_dom, "NTLMv2 and LMv2, LMv2 broken (no domain)", false}, + {test_ntlmv2_ntlmv2_broken, "NTLMv2 and LMv2, NTLMv2 broken", false}, #if 0 - {test_ntlmv2_ntlmv2_broken_no_dom, "NTLMv2 and LMv2, NTLMv2 broken (no domain)", False}, + {test_ntlmv2_ntlmv2_broken_no_dom, "NTLMv2 and LMv2, NTLMv2 broken (no domain)", false}, #endif - {test_ntlmv2_both_broken, "NTLMv2 and LMv2, both broken", False}, - {test_ntlmv2_both_broken_no_dom, "NTLMv2 and LMv2, both broken (no domain)", False}, - {test_ntlm_lm_broken, "NTLM and LM, LM broken", False}, - {test_ntlm_ntlm_broken, "NTLM and LM, NTLM broken", False}, - {test_ntlm2, "NTLM2 (NTLMv2 session security)", False}, - {test_lmv2_ntlm_both_broken, "LMv2 and NTLM, both broken", False}, - {test_lmv2_ntlm_both_broken_no_dom, "LMv2 and NTLM, both broken (no domain)", False}, - {test_lmv2_ntlm_break_ntlm, "LMv2 and NTLM, NTLM broken", False}, - {test_lmv2_ntlm_break_ntlm_no_dom, "LMv2 and NTLM, NTLM broken (no domain)", False}, - {test_lmv2_ntlm_break_lm, "LMv2 and NTLM, LMv2 broken", False}, - {test_lmv2_ntlm_break_lm_no_dom, "LMv2 and NTLM, LMv2 broken (no domain)", False}, - {test_plaintext_none_broken, "Plaintext", False}, - {test_plaintext_lm_broken, "Plaintext LM broken", False}, - {test_plaintext_nt_broken, "Plaintext NT broken", False}, - {test_plaintext_nt_only, "Plaintext NT only", False}, - {test_plaintext_lm_only, "Plaintext LM only", False}, + {test_ntlmv2_both_broken, "NTLMv2 and LMv2, both broken", false}, + {test_ntlmv2_both_broken_no_dom, "NTLMv2 and LMv2, both broken (no domain)", false}, + {test_ntlm_lm_broken, "NTLM and LM, LM broken", false}, + {test_ntlm_ntlm_broken, "NTLM and LM, NTLM broken", false}, + {test_ntlm2, "NTLM2 (NTLMv2 session security)", false}, + {test_lmv2_ntlm_both_broken, "LMv2 and NTLM, both broken", false}, + {test_lmv2_ntlm_both_broken_no_dom, "LMv2 and NTLM, both broken (no domain)", false}, + {test_lmv2_ntlm_break_ntlm, "LMv2 and NTLM, NTLM broken", false}, + {test_lmv2_ntlm_break_ntlm_no_dom, "LMv2 and NTLM, NTLM broken (no domain)", false}, + {test_lmv2_ntlm_break_lm, "LMv2 and NTLM, LMv2 broken", false}, + {test_lmv2_ntlm_break_lm_no_dom, "LMv2 and NTLM, LMv2 broken (no domain)", false}, + {test_plaintext_none_broken, "Plaintext", false}, + {test_plaintext_lm_broken, "Plaintext LM broken", false}, + {test_plaintext_nt_broken, "Plaintext NT broken", false}, + {test_plaintext_nt_only, "Plaintext NT only", false}, + {test_plaintext_lm_only, "Plaintext LM only", false}, {NULL, NULL} }; /* try a netlogon SamLogon */ -static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct creds_CredentialState *creds, const char *comment, const char *account_domain, const char *account_name, const char *plain_pass, uint32_t parameter_control, - NTSTATUS expected_error, BOOL old_password, + NTSTATUS expected_error, bool old_password, int n_subtests) { TALLOC_CTX *fn_ctx = talloc_named(mem_ctx, 0, "test_SamLogon function-level context"); int i, v, l, f; - BOOL ret = True; + bool ret = true; int validation_levels[] = {2,3,6}; int logon_levels[] = { 2, 6 }; int function_levels[] = { @@ -1383,7 +1384,7 @@ static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, d_printf(" failed (expected, test incomplete): %s\n", error_string); } else { d_printf(" failed: %s\n", error_string); - ret = False; + ret = false; } SAFE_FREE(error_string); } @@ -1399,7 +1400,7 @@ static BOOL test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, /* test an ADS style interactive domain logon */ -BOOL test_InteractiveLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_InteractiveLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct creds_CredentialState *creds, const char *comment, const char *workstation_name, @@ -1455,7 +1456,7 @@ BOOL test_InteractiveLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, || !creds_client_check(creds, &r.out.return_authenticator->cred)) { d_printf("Credential chaining failed\n"); talloc_free(fn_ctx); - return False; + return false; } talloc_free(fn_ctx); @@ -1463,22 +1464,22 @@ BOOL test_InteractiveLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(expected_error, status)) { d_printf("[%s]\\[%s] netr_LogonSamLogonWithFlags - expected %s got %s\n", account_domain, account_name, nt_errstr(expected_error), nt_errstr(status)); - return False; + return false; } - return True; + return true; } -BOOL torture_rpc_samlogon(struct torture_context *torture) +bool torture_rpc_samlogon(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; struct dcerpc_binding *b; struct cli_credentials *machine_credentials; TALLOC_CTX *mem_ctx = talloc_init("torture_rpc_netlogon"); - BOOL ret = True; + bool ret = true; struct test_join *join_ctx = NULL; struct test_join *user_ctx = NULL, *user_ctx_wrong_wks = NULL, *user_ctx_wrong_time = NULL; char *user_password, *user_password_wrong_wks, *user_password_wrong_time; @@ -1508,10 +1509,10 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) &machine_credentials); if (!join_ctx) { d_printf("Failed to join as Workstation\n"); - return False; + return false; } - userdomain = torture_setting_string(torture, "userdomain", lp_workgroup()); + userdomain = torture_setting_string(torture, "userdomain", lp_workgroup(global_loadparm)); user_ctx = torture_create_testuser(torture, TEST_USER_NAME, @@ -1520,14 +1521,14 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) (const char **)&user_password); if (!user_ctx) { d_printf("Failed to create a test user\n"); - return False; + return false; } old_user_password = user_password; test_ChangePasswordUser3(torture_join_samr_pipe(user_ctx), mem_ctx, TEST_USER_NAME, 16 /* > 14 */, &user_password, - NULL, 0, False); + NULL, 0, false); user_ctx_wrong_wks = torture_create_testuser(torture, TEST_USER_NAME_WRONG_WKS, @@ -1536,7 +1537,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) (const char **)&user_password_wrong_wks); if (!user_ctx_wrong_wks) { d_printf("Failed to create a test user (wrong workstation test)\n"); - return False; + return false; } ZERO_STRUCT(u); @@ -1550,7 +1551,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) status = dcerpc_samr_SetUserInfo(torture_join_samr_pipe(user_ctx_wrong_wks), mem_ctx, &s); if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo (list of workstations) failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; goto failed; } @@ -1561,7 +1562,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) (const char **)&user_password_wrong_time); if (!user_ctx_wrong_time) { d_printf("Failed to create a test user (wrong workstation test)\n"); - return False; + return false; } ZERO_STRUCT(u); @@ -1572,18 +1573,18 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) u.info21.fields_present = SAMR_FIELD_WORKSTATIONS | SAMR_FIELD_LOGON_HOURS; u.info21.workstations.string = TEST_MACHINE_NAME; u.info21.logon_hours.units_per_week = 168; - u.info21.logon_hours.bits = talloc_zero_size(mem_ctx, 168); + u.info21.logon_hours.bits = talloc_zero_array(mem_ctx, uint8_t, 168); status = dcerpc_samr_SetUserInfo(torture_join_samr_pipe(user_ctx_wrong_time), mem_ctx, &s); if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo (logon times and list of workstations) failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; goto failed; } status = torture_rpc_binding(torture, &b); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto failed; } @@ -1599,13 +1600,13 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { d_printf("RPC pipe connect as domain member failed: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto failed; } status = dcerpc_schannel_creds(p->conn->security_state.generic_state, mem_ctx, &creds); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto failed; } @@ -1616,18 +1617,18 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) const char *domain; const char *username; const char *password; - BOOL network_login; + bool network_login; NTSTATUS expected_interactive_error; NTSTATUS expected_network_error; uint32_t parameter_control; - BOOL old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */ + bool old_password; /* Allow an old password to be accepted or rejected without error, as well as session key bugs */ } usercreds[] = { { .comment = "domain\\user", .domain = cli_credentials_get_domain(cmdline_credentials), .username = cli_credentials_get_username(cmdline_credentials), .password = cli_credentials_get_password(cmdline_credentials), - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_OK, .expected_network_error = NT_STATUS_OK }, @@ -1636,7 +1637,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) .domain = cli_credentials_get_realm(cmdline_credentials), .username = cli_credentials_get_username(cmdline_credentials), .password = cli_credentials_get_password(cmdline_credentials), - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_OK, .expected_network_error = NT_STATUS_OK }, @@ -1649,7 +1650,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) cli_credentials_get_domain(cmdline_credentials) ), .password = cli_credentials_get_password(cmdline_credentials), - .network_login = False, /* works for some things, but not NTLMv2. Odd */ + .network_login = false, /* works for some things, but not NTLMv2. Odd */ .expected_interactive_error = NT_STATUS_OK, .expected_network_error = NT_STATUS_OK }, @@ -1662,7 +1663,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) cli_credentials_get_realm(cmdline_credentials) ), .password = cli_credentials_get_password(cmdline_credentials), - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_OK, .expected_network_error = NT_STATUS_OK }, @@ -1671,7 +1672,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) .domain = cli_credentials_get_domain(machine_credentials), .username = cli_credentials_get_username(machine_credentials), .password = cli_credentials_get_password(machine_credentials), - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_NO_SUCH_USER, .parameter_control = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT }, @@ -1680,7 +1681,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) .domain = cli_credentials_get_domain(machine_credentials), .username = cli_credentials_get_username(machine_credentials), .password = cli_credentials_get_password(machine_credentials), - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_NO_SUCH_USER, .expected_network_error = NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT }, @@ -1689,7 +1690,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) .domain = cli_credentials_get_realm(machine_credentials), .username = cli_credentials_get_username(machine_credentials), .password = cli_credentials_get_password(machine_credentials), - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_NO_SUCH_USER, .parameter_control = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT }, @@ -1702,7 +1703,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) cli_credentials_get_domain(machine_credentials) ), .password = cli_credentials_get_password(machine_credentials), - .network_login = False, /* works for some things, but not NTLMv2. Odd */ + .network_login = false, /* works for some things, but not NTLMv2. Odd */ .expected_interactive_error = NT_STATUS_NO_SUCH_USER, .parameter_control = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT }, @@ -1715,7 +1716,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) cli_credentials_get_realm(machine_credentials) ), .password = cli_credentials_get_password(machine_credentials), - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_NO_SUCH_USER, .parameter_control = MSV1_0_ALLOW_WORKSTATION_TRUST_ACCOUNT }, @@ -1724,7 +1725,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) .domain = userdomain, .username = TEST_USER_NAME, .password = user_password, - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_OK, .expected_network_error = NT_STATUS_OK }, @@ -1734,9 +1735,9 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) .username = talloc_asprintf(mem_ctx, "%s@%s", TEST_USER_NAME, - lp_realm()), + lp_realm(global_loadparm)), .password = user_password, - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_OK, .expected_network_error = NT_STATUS_OK }, @@ -1748,7 +1749,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) TEST_USER_NAME, userdomain), .password = user_password, - .network_login = False, /* works for some things, but not NTLMv2. Odd */ + .network_login = false, /* works for some things, but not NTLMv2. Odd */ .expected_interactive_error = NT_STATUS_OK, .expected_network_error = NT_STATUS_OK }, @@ -1758,17 +1759,17 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) .domain = userdomain, .username = TEST_USER_NAME, .password = old_user_password, - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_WRONG_PASSWORD, .expected_network_error = NT_STATUS_OK, - .old_password = True + .old_password = true }, { .comment = "test user (wong workstation): domain\\user", .domain = userdomain, .username = TEST_USER_NAME_WRONG_WKS, .password = user_password_wrong_wks, - .network_login = True, + .network_login = true, .expected_interactive_error = NT_STATUS_INVALID_WORKSTATION, .expected_network_error = NT_STATUS_INVALID_WORKSTATION } @@ -1785,7 +1786,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) usercreds[ci].password, usercreds[ci].parameter_control, usercreds[ci].expected_interactive_error)) { - ret = False; + ret = false; } if (usercreds[ci].network_login) { @@ -1798,7 +1799,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) usercreds[ci].expected_network_error, usercreds[ci].old_password, 0)) { - ret = False; + ret = false; } } } @@ -1818,7 +1819,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) usercreds[0].password, usercreds[0].parameter_control, usercreds[0].expected_interactive_error)) { - ret = False; + ret = false; } if (usercreds[0].network_login) { @@ -1831,7 +1832,7 @@ BOOL torture_rpc_samlogon(struct torture_context *torture) usercreds[0].expected_network_error, usercreds[0].old_password, 1)) { - ret = False; + ret = false; } } } diff --git a/source4/torture/rpc/samr.c b/source4/torture/rpc/samr.c index 8d3164967a..ec70c91570 100644 --- a/source4/torture/rpc/samr.c +++ b/source4/torture/rpc/samr.c @@ -28,6 +28,7 @@ #include "libcli/auth/libcli_auth.h" #include "libcli/security/security.h" #include "torture/rpc/rpc.h" +#include "param/param.h" #define TEST_ACCOUNT_NAME "samrtorturetest" #define TEST_ALIASNAME "samrtorturetestalias" @@ -41,16 +42,16 @@ enum torture_samr_choice { TORTURE_SAMR_OTHER }; -static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle); -static BOOL test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle); -static BOOL test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle); -static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *acct_name, struct policy_handle *domain_handle, char **password); @@ -59,7 +60,7 @@ static void init_lsa_String(struct lsa_String *string, const char *s) string->string = s; } -BOOL test_samr_handle_Close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_samr_handle_Close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -71,21 +72,21 @@ BOOL test_samr_handle_Close(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Close(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Close handle failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_Shutdown(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +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_bool(-1, "torture", "dangerous", False)) { + if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) { printf("samr_Shutdown disabled - enable dangerous tests to use\n"); - return True; + return true; } r.in.connect_handle = handle; @@ -95,13 +96,13 @@ static BOOL test_Shutdown(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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 false; } - return True; + return true; } -static BOOL test_SetDsrmPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetDsrmPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -109,9 +110,9 @@ static BOOL test_SetDsrmPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct lsa_String string; struct samr_Password hash; - if (!lp_parm_bool(-1, "torture", "dangerous", False)) { + if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) { printf("samr_SetDsrmPassword disabled - enable dangerous tests to use\n"); - return True; + return true; } E_md4hash("TeSTDSRM123", hash.hash); @@ -127,14 +128,14 @@ static BOOL test_SetDsrmPassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, 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 false; } - return True; + return true; } -static BOOL test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -147,39 +148,39 @@ static BOOL test_QuerySecurity(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_QuerySecurity(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("QuerySecurity failed - %s\n", nt_errstr(status)); - return False; + return false; } if (r.out.sdbuf == NULL) { - return False; + return false; } s.in.handle = handle; s.in.sec_info = 7; s.in.sdbuf = r.out.sdbuf; - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping SetSecurity test against Samba4\n"); - return True; + return true; } status = dcerpc_samr_SetSecurity(p, mem_ctx, &s); if (!NT_STATUS_IS_OK(status)) { printf("SetSecurity failed - %s\n", nt_errstr(status)); - return False; + return false; } status = dcerpc_samr_QuerySecurity(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("QuerySecurity failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint32_t base_acct_flags, const char *base_account_name) { @@ -189,7 +190,7 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_QueryUserInfo q; struct samr_QueryUserInfo q0; union samr_UserInfo u; - BOOL ret = True; + bool ret = true; const char *test_account_name; uint32_t user_extra_flags = 0; @@ -213,7 +214,7 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { \ printf(#call " level %u failed - %s (%s)\n", \ r.in.level, nt_errstr(status), __location__); \ - ret = False; \ + ret = false; \ break; \ } @@ -221,15 +222,15 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if ((s1 && !s2) || (s2 && !s1) || strcmp(s1, s2)) { \ printf("Failed to set %s to '%s' (%s)\n", \ #field, s2, __location__); \ - ret = False; \ + ret = false; \ break; \ } #define INT_EQUAL(i1, i2, field) \ if (i1 != i2) { \ - printf("Failed to set %s to 0x%x - got 0x%x (%s)\n", \ - #field, i2, i1, __location__); \ - ret = False; \ + printf("Failed to set %s to 0x%llx - got 0x%llx (%s)\n", \ + #field, (unsigned long long)i2, (unsigned long long)i1, __location__); \ + ret = false; \ break; \ } @@ -373,23 +374,40 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, TEST_USERINFO_STRING(14, workstations, 21, workstations, "14workstation21", 0); TEST_USERINFO_STRING(21, workstations, 21, workstations, "21workstation21", SAMR_FIELD_WORKSTATIONS); + TEST_USERINFO_STRING(21, workstations, 3, workstations, "21workstation3", + SAMR_FIELD_WORKSTATIONS); + TEST_USERINFO_STRING(21, workstations, 5, workstations, "21workstation5", + SAMR_FIELD_WORKSTATIONS); + TEST_USERINFO_STRING(21, workstations, 14, workstations, "21workstation14", + SAMR_FIELD_WORKSTATIONS); TEST_USERINFO_STRING(20, parameters, 21, parameters, "xx20-21 parameters", 0); TEST_USERINFO_STRING(21, parameters, 21, parameters, "xx21-21 parameters", SAMR_FIELD_PARAMETERS); + TEST_USERINFO_STRING(21, parameters, 20, parameters, "xx21-20 parameters", + SAMR_FIELD_PARAMETERS); + TEST_USERINFO_INT(2, country_code, 2, country_code, __LINE__, 0); TEST_USERINFO_INT(2, country_code, 21, country_code, __LINE__, 0); TEST_USERINFO_INT(21, country_code, 21, country_code, __LINE__, SAMR_FIELD_COUNTRY_CODE); + TEST_USERINFO_INT(21, country_code, 2, country_code, __LINE__, + SAMR_FIELD_COUNTRY_CODE); TEST_USERINFO_INT(2, code_page, 21, code_page, __LINE__, 0); TEST_USERINFO_INT(21, code_page, 21, code_page, __LINE__, SAMR_FIELD_CODE_PAGE); + TEST_USERINFO_INT(21, code_page, 2, code_page, __LINE__, + SAMR_FIELD_CODE_PAGE); TEST_USERINFO_INT(17, acct_expiry, 21, acct_expiry, __LINE__, 0); TEST_USERINFO_INT(17, acct_expiry, 5, acct_expiry, __LINE__, 0); TEST_USERINFO_INT(21, acct_expiry, 21, acct_expiry, __LINE__, SAMR_FIELD_ACCT_EXPIRY); + TEST_USERINFO_INT(21, acct_expiry, 5, acct_expiry, __LINE__, + SAMR_FIELD_ACCT_EXPIRY); + TEST_USERINFO_INT(21, acct_expiry, 17, acct_expiry, __LINE__, + SAMR_FIELD_ACCT_EXPIRY); TEST_USERINFO_INT(4, logon_hours.bits[3], 3, logon_hours.bits[3], 1, 0); TEST_USERINFO_INT(4, logon_hours.bits[3], 5, logon_hours.bits[3], 2, 0); @@ -397,7 +415,7 @@ static BOOL test_SetUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, TEST_USERINFO_INT(21, logon_hours.bits[3], 21, logon_hours.bits[3], 4, SAMR_FIELD_LOGON_HOURS); - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping Set Account Flag tests against Samba4\n"); return ret; } @@ -493,13 +511,13 @@ static char *samr_rand_pass_fixed_len(TALLOC_CTX *mem_ctx, int len) return s; } -static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, char **password) { NTSTATUS status; struct samr_SetUserInfo s; union samr_UserInfo u; - BOOL ret = True; + bool ret = true; DATA_BLOB session_key; char *newpass; struct samr_GetUserPwInfo pwp; @@ -524,7 +542,7 @@ static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); - return False; + return false; } arcfour_crypt_blob(u.info24.password.data, 516, &session_key); @@ -535,7 +553,7 @@ static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo level %u failed - %s\n", s.in.level, nt_errstr(status)); - ret = False; + ret = false; } else { *password = newpass; } @@ -544,14 +562,14 @@ static BOOL test_SetUserPass(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint32_t fields_present, char **password) { NTSTATUS status; struct samr_SetUserInfo s; union samr_UserInfo u; - BOOL ret = True; + bool ret = true; DATA_BLOB session_key; char *newpass; struct samr_GetUserPwInfo pwp; @@ -578,7 +596,7 @@ static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); - return False; + return false; } arcfour_crypt_blob(u.info23.password.data, 516, &session_key); @@ -589,7 +607,7 @@ static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo level %u failed - %s\n", s.in.level, nt_errstr(status)); - ret = False; + ret = false; } else { *password = newpass; } @@ -600,7 +618,7 @@ static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); - return False; + return false; } /* This should break the key nicely */ @@ -613,21 +631,21 @@ static BOOL test_SetUserPass_23(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("SetUserInfo level %u should have failed with WRONG_PASSWORD- %s\n", s.in.level, nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, bool makeshort, char **password) { NTSTATUS status; struct samr_SetUserInfo s; union samr_UserInfo u; - BOOL ret = True; + bool ret = true; DATA_BLOB session_key; DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16); uint8_t confounder[16]; @@ -658,7 +676,7 @@ static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); - return False; + return false; } generate_random_buffer((uint8_t *)confounder, 16); @@ -677,7 +695,7 @@ static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo level %u failed - %s\n", s.in.level, nt_errstr(status)); - ret = False; + ret = false; } else { *password = newpass; } @@ -694,7 +712,7 @@ static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("SetUserInfo level %u should have failed with WRONG_PASSWORD: %s\n", s.in.level, nt_errstr(status)); - ret = False; + ret = false; } else { *password = newpass; } @@ -702,14 +720,14 @@ static BOOL test_SetUserPassEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint32_t fields_present, char **password) { NTSTATUS status; struct samr_SetUserInfo s; union samr_UserInfo u; - BOOL ret = True; + bool ret = true; DATA_BLOB session_key; DATA_BLOB confounded_session_key = data_blob_talloc(mem_ctx, NULL, 16); struct MD5Context ctx; @@ -739,7 +757,7 @@ static BOOL test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo level %u - no session key - %s\n", s.in.level, nt_errstr(status)); - return False; + return false; } generate_random_buffer((uint8_t *)confounder, 16); @@ -758,7 +776,7 @@ static BOOL test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetUserInfo level %u failed - %s\n", s.in.level, nt_errstr(status)); - ret = False; + ret = false; } else { *password = newpass; } @@ -775,13 +793,13 @@ static BOOL test_SetUserPass_25(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("SetUserInfo level %u should have failed with WRONG_PASSWORD- %s\n", s.in.level, nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -789,7 +807,7 @@ static BOOL test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_QueryAliasInfo q; uint16_t levels[] = {2, 3}; int i; - BOOL ret = True; + bool ret = true; /* Ignoring switch level 1, as that includes the number of members for the alias * and setting this to a wrong value might have negative consequences @@ -811,7 +829,7 @@ static BOOL test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetAliasInfo level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } q.in.alias_handle = handle; @@ -821,19 +839,19 @@ static BOOL test_SetAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryAliasInfo level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } } return ret; } -static BOOL test_GetGroupsForUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetGroupsForUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *user_handle) { struct samr_GetGroupsForUser r; NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("testing GetGroupsForUser\n"); @@ -842,19 +860,19 @@ static BOOL test_GetGroupsForUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_GetGroupsForUser(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("GetGroupsForUser failed - %s\n",nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct lsa_String *domain_name) { NTSTATUS status; struct samr_GetDomPwInfo r; - BOOL ret = True; + bool ret = true; r.in.domain_name = domain_name; printf("Testing GetDomPwInfo with name %s\n", r.in.domain_name->string); @@ -862,7 +880,7 @@ static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("GetDomPwInfo failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } r.in.domain_name->string = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); @@ -871,7 +889,7 @@ static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("GetDomPwInfo failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } r.in.domain_name->string = "\\\\__NONAME__"; @@ -880,7 +898,7 @@ static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("GetDomPwInfo failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } r.in.domain_name->string = "\\\\Builtin"; @@ -889,19 +907,19 @@ static BOOL test_GetDomPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("GetDomPwInfo failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_GetUserPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetUserPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_GetUserPwInfo r; - BOOL ret = True; + bool ret = true; printf("Testing GetUserPwInfo\n"); @@ -910,7 +928,7 @@ static BOOL test_GetUserPwInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_GetUserPwInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("GetUserPwInfo failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; @@ -1006,12 +1024,12 @@ static NTSTATUS test_OpenUser_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } #if 0 -static BOOL test_ChangePasswordNT3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_ChangePasswordNT3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_ChangePasswordUser r; - BOOL ret = True; + bool ret = true; struct samr_Password hash1, hash2, hash3, hash4, hash5, hash6; struct policy_handle user_handle; char *oldpass = "test"; @@ -1021,7 +1039,7 @@ static BOOL test_ChangePasswordNT3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = test_OpenUser_byname(p, mem_ctx, handle, "testuser", &user_handle); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } printf("Testing ChangePasswordUser for user 'testuser'\n"); @@ -1056,30 +1074,30 @@ static BOOL test_ChangePasswordNT3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("ChangePasswordUser failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) { - ret = False; + ret = false; } return ret; } #endif -static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *acct_name, struct policy_handle *handle, char **password) { NTSTATUS status; struct samr_ChangePasswordUser r; - BOOL ret = True; + bool ret = true; struct samr_Password hash1, hash2, hash3, hash4, hash5, hash6; struct policy_handle user_handle; char *oldpass; uint8_t old_nt_hash[16], new_nt_hash[16]; uint8_t old_lm_hash[16], new_lm_hash[16]; - BOOL changed = True; + bool changed = true; char *newpass; struct samr_GetUserPwInfo pwp; @@ -1087,7 +1105,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = test_OpenUser_byname(p, mem_ctx, handle, acct_name, &user_handle); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } pwp.in.user_handle = &user_handle; @@ -1101,7 +1119,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!*password) { printf("Failing ChangePasswordUser as old password was NULL. Previous test failed?\n"); - return False; + return false; } oldpass = *password; @@ -1135,7 +1153,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we broke the LM hash, got %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* Unbreak the LM hash */ @@ -1158,7 +1176,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we broke the NT hash, got %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* Unbreak the NT hash */ @@ -1181,7 +1199,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we broke the LM cross-hash, got %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* Unbreak the LM cross */ @@ -1204,7 +1222,7 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we broke the NT cross-hash, got %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* Unbreak the NT cross */ @@ -1233,11 +1251,11 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r); if (NT_STATUS_IS_OK(status)) { - changed = True; + changed = true; *password = newpass; } else if (!NT_STATUS_EQUAL(NT_STATUS_PASSWORD_RESTRICTION, status)) { printf("ChangePasswordUser failed: expected NT_STATUS_OK, or at least NT_STATUS_PASSWORD_RESTRICTION, got %s\n", nt_errstr(status)); - ret = False; + ret = false; } oldpass = newpass; @@ -1271,11 +1289,11 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_ChangePasswordUser(p, mem_ctx, &r); if (NT_STATUS_IS_OK(status)) { - changed = True; + changed = true; *password = newpass; } else if (!NT_STATUS_EQUAL(NT_STATUS_PASSWORD_RESTRICTION, status)) { printf("ChangePasswordUser failed: expected NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED, got %s\n", nt_errstr(status)); - ret = False; + ret = false; } oldpass = newpass; @@ -1312,9 +1330,9 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("ChangePasswordUser returned: %s perhaps min password age? (not fatal)\n", nt_errstr(status)); } else if (!NT_STATUS_IS_OK(status)) { printf("ChangePasswordUser failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { - changed = True; + changed = true; *password = newpass; } @@ -1336,26 +1354,26 @@ static BOOL test_ChangePasswordUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("ChangePasswordUser returned: %s perhaps min password age? (not fatal)\n", nt_errstr(status)); } else if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("ChangePasswordUser failed: expected NT_STATUS_WRONG_PASSWORD because we already changed the password, got %s\n", nt_errstr(status)); - ret = False; + ret = false; } } if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) { - ret = False; + ret = false; } return ret; } -static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *acct_name, struct policy_handle *handle, char **password) { NTSTATUS status; struct samr_OemChangePasswordUser2 r; - BOOL ret = True; + bool ret = true; struct samr_Password lm_verifier; struct samr_CryptPassword lm_pass; struct lsa_AsciiString server, account, account_bad; @@ -1375,7 +1393,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c if (!*password) { printf("Failing OemChangePasswordUser2 as old password was NULL. Previous test failed?\n"); - return False; + return false; } oldpass = *password; @@ -1411,7 +1429,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c && !NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD (or at least 'PASSWORD_RESTRICTON') for invalid password verifier - %s\n", nt_errstr(status)); - ret = False; + ret = false; } encode_pw_buffer(lm_pass.data, newpass, STR_ASCII); @@ -1433,7 +1451,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c && !NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD (or at least 'PASSWORD_RESTRICTON') for invalidly encrpted password - %s\n", nt_errstr(status)); - ret = False; + ret = false; } encode_pw_buffer(lm_pass.data, newpass, STR_ASCII); @@ -1450,7 +1468,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c && !NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { printf("ChangePasswordUser3 failed, should have returned INVALID_PARAMETER (or at least 'PASSWORD_RESTRICTON') for no supplied validation hash - %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* This shouldn't be a valid name */ @@ -1462,7 +1480,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { printf("ChangePasswordUser3 failed, should have returned INVALID_PARAMETER for no supplied validation hash and invalid user - %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* This shouldn't be a valid name */ @@ -1476,7 +1494,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD for invalid user - %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* This shouldn't be a valid name */ @@ -1490,7 +1508,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c if (!NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) { printf("ChangePasswordUser3 failed, should have returned INVALID_PARAMETER for no supplied password and invalid user - %s\n", nt_errstr(status)); - ret = False; + ret = false; } E_deshash(oldpass, old_lm_hash); @@ -1510,7 +1528,7 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c printf("OemChangePasswordUser2 returned: %s perhaps min password age? (not fatal)\n", nt_errstr(status)); } else if (!NT_STATUS_IS_OK(status)) { printf("OemChangePasswordUser2 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { *password = newpass; } @@ -1519,14 +1537,14 @@ static BOOL test_OemChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_c } -static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *acct_name, char **password, char *newpass, bool allow_password_restriction) { NTSTATUS status; struct samr_ChangePasswordUser2 r; - BOOL ret = True; + bool ret = true; struct lsa_String server, account; struct samr_CryptPassword nt_pass, lm_pass; struct samr_Password nt_verifier, lm_verifier; @@ -1545,7 +1563,7 @@ static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!*password) { printf("Failing ChangePasswordUser3 as old password was NULL. Previous test failed?\n"); - return False; + return false; } oldpass = *password; @@ -1589,7 +1607,7 @@ static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("ChangePasswordUser2 returned: %s perhaps min password age? (not fatal)\n", nt_errstr(status)); } else if (!NT_STATUS_IS_OK(status)) { printf("ChangePasswordUser2 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { *password = newpass; } @@ -1598,17 +1616,17 @@ static BOOL test_ChangePasswordUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *account_string, int policy_min_pw_len, char **password, const char *newpass, NTTIME last_password_change, - BOOL handle_reject_reason) + bool handle_reject_reason) { NTSTATUS status; struct samr_ChangePasswordUser3 r; - BOOL ret = True; + bool ret = true; struct lsa_String server, account, account_bad; struct samr_CryptPassword nt_pass, lm_pass; struct samr_Password nt_verifier, lm_verifier; @@ -1626,14 +1644,14 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } else { newpass = samr_rand_pass_fixed_len(mem_ctx, policy_min_pw_len); } - } while (check_password_quality(newpass) == False); + } while (check_password_quality(newpass) == false); } else { printf("Using password '%s'\n", newpass); } if (!*password) { printf("Failing ChangePasswordUser3 as old password was NULL. Previous test failed?\n"); - return False; + return false; } oldpass = *password; @@ -1671,7 +1689,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD))) { printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD (or at least 'PASSWORD_RESTRICTON') for invalid password verifier - %s\n", nt_errstr(status)); - ret = False; + ret = false; } encode_pw_buffer(lm_pass.data, newpass, STR_UNICODE); @@ -1700,7 +1718,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD))) { printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD (or at least 'PASSWORD_RESTRICTON') for invalidly encrpted password - %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* This shouldn't be a valid name */ @@ -1711,7 +1729,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(status, NT_STATUS_WRONG_PASSWORD)) { printf("ChangePasswordUser3 failed, should have returned WRONG_PASSWORD for invalid username - %s\n", nt_errstr(status)); - ret = False; + ret = false; } E_md4hash(oldpass, old_nt_hash); @@ -1751,7 +1769,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (r.out.reject && (r.out.reject->reason != SAMR_REJECT_OTHER)) { printf("expected SAMR_REJECT_OTHER (%d), got %d\n", SAMR_REJECT_OTHER, r.out.reject->reason); - return False; + return false; } } @@ -1770,7 +1788,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (r.out.reject->reason != SAMR_REJECT_OTHER) { printf("expected SAMR_REJECT_OTHER (%d), got %d\n", SAMR_REJECT_OTHER, r.out.reject->reason); - return False; + return false; } } else if ((r.out.dominfo->min_password_length > 0) && @@ -1779,7 +1797,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (r.out.reject->reason != SAMR_REJECT_TOO_SHORT) { printf("expected SAMR_REJECT_TOO_SHORT (%d), got %d\n", SAMR_REJECT_TOO_SHORT, r.out.reject->reason); - return False; + return false; } } else if ((r.out.dominfo->password_history_length > 0) && @@ -1788,14 +1806,14 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (r.out.reject->reason != SAMR_REJECT_IN_HISTORY) { printf("expected SAMR_REJECT_IN_HISTORY (%d), got %d\n", SAMR_REJECT_IN_HISTORY, r.out.reject->reason); - return False; + return false; } } else if (r.out.dominfo->password_properties & DOMAIN_PASSWORD_COMPLEX) { if (r.out.reject->reason != SAMR_REJECT_COMPLEXITY) { printf("expected SAMR_REJECT_COMPLEXITY (%d), got %d\n", SAMR_REJECT_COMPLEXITY, r.out.reject->reason); - return False; + return false; } } @@ -1804,7 +1822,7 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, /* retry with adjusted size */ return test_ChangePasswordUser3(p, mem_ctx, account_string, r.out.dominfo->min_password_length, - password, NULL, 0, False); + password, NULL, 0, false); } @@ -1812,13 +1830,13 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (r.out.reject && r.out.reject->reason != SAMR_REJECT_OTHER) { printf("expected SAMR_REJECT_OTHER (%d), got %d\n", SAMR_REJECT_OTHER, r.out.reject->reason); - return False; + return false; } /* Perhaps the server has a 'min password age' set? */ } else if (!NT_STATUS_IS_OK(status)) { printf("ChangePasswordUser3 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { *password = talloc_strdup(mem_ctx, newpass); } @@ -1827,13 +1845,13 @@ BOOL test_ChangePasswordUser3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -static BOOL test_GetMembersInAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetMembersInAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *alias_handle) { struct samr_GetMembersInAlias r; struct lsa_SidArray sids; NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("Testing GetMembersInAlias\n"); @@ -1844,20 +1862,20 @@ static BOOL test_GetMembersInAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("GetMembersInAlias failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *alias_handle, const struct dom_sid *domain_sid) { struct samr_AddAliasMember r; struct samr_DeleteAliasMember d; NTSTATUS status; - BOOL ret = True; + bool ret = true; struct dom_sid *sid; sid = dom_sid_add_rid(mem_ctx, domain_sid, 512); @@ -1869,7 +1887,7 @@ static BOOL test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_AddAliasMember(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("AddAliasMember failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } d.in.alias_handle = alias_handle; @@ -1878,19 +1896,19 @@ static BOOL test_AddMemberToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_DeleteAliasMember(p, mem_ctx, &d); if (!NT_STATUS_IS_OK(status)) { printf("DelAliasMember failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *alias_handle) { struct samr_AddMultipleMembersToAlias a; struct samr_RemoveMultipleMembersFromAlias r; NTSTATUS status; - BOOL ret = True; + bool ret = true; struct lsa_SidArray sids; printf("testing AddMultipleMembersToAlias\n"); @@ -1907,7 +1925,7 @@ static BOOL test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *me status = dcerpc_samr_AddMultipleMembersToAlias(p, mem_ctx, &a); if (!NT_STATUS_IS_OK(status)) { printf("AddMultipleMembersToAlias failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } @@ -1918,14 +1936,14 @@ static BOOL test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *me status = dcerpc_samr_RemoveMultipleMembersFromAlias(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("RemoveMultipleMembersFromAlias failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* strange! removing twice doesn't give any error */ status = dcerpc_samr_RemoveMultipleMembersFromAlias(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("RemoveMultipleMembersFromAlias failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } /* but removing an alias that isn't there does */ @@ -1934,18 +1952,18 @@ static BOOL test_AddMultipleMembersToAlias(struct dcerpc_pipe *p, TALLOC_CTX *me status = dcerpc_samr_RemoveMultipleMembersFromAlias(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(NT_STATUS_OBJECT_NAME_NOT_FOUND, status)) { printf("RemoveMultipleMembersFromAlias failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_TestPrivateFunctionsUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_TestPrivateFunctionsUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *user_handle) { struct samr_TestPrivateFunctionsUser r; NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("Testing TestPrivateFunctionsUser\n"); @@ -1954,14 +1972,14 @@ static BOOL test_TestPrivateFunctionsUser(struct dcerpc_pipe *p, TALLOC_CTX *mem status = dcerpc_samr_TestPrivateFunctionsUser(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(NT_STATUS_NOT_IMPLEMENTED, status)) { printf("TestPrivateFunctionsUser failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *user_handle, struct policy_handle *domain_handle, uint32_t base_acct_flags, @@ -1970,7 +1988,7 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, TALLOC_CTX *user_ctx; char *password = NULL; - BOOL ret = True; + bool ret = true; int i; const uint32_t password_fields[] = { SAMR_FIELD_PASSWORD, @@ -1983,32 +2001,32 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, switch (which_ops) { case TORTURE_SAMR_USER_ATTRIBUTES: if (!test_QuerySecurity(p, user_ctx, user_handle)) { - ret = False; + ret = false; } if (!test_QueryUserInfo(p, user_ctx, user_handle)) { - ret = False; + ret = false; } if (!test_QueryUserInfo2(p, user_ctx, user_handle)) { - ret = False; + ret = false; } if (!test_SetUserInfo(p, user_ctx, user_handle, base_acct_flags, base_acct_name)) { - ret = False; + ret = false; } if (!test_GetUserPwInfo(p, user_ctx, user_handle)) { - ret = False; + ret = false; } if (!test_TestPrivateFunctionsUser(p, user_ctx, user_handle)) { - ret = False; + ret = false; } if (!test_SetUserPass(p, user_ctx, user_handle, &password)) { - ret = False; + ret = false; } break; case TORTURE_SAMR_PASSWORDS: @@ -2023,53 +2041,53 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, /* Workstation trust accounts don't seem to need to honour password quality policy */ if (!test_SetUserPassEx(p, user_ctx, user_handle, true, &password)) { - ret = False; + ret = false; } - if (!test_ChangePasswordUser2(p, user_ctx, base_acct_name, &password, simple_pass, False)) { - ret = False; + if (!test_ChangePasswordUser2(p, user_ctx, base_acct_name, &password, simple_pass, false)) { + ret = false; } /* reset again, to allow another 'user' password change */ if (!test_SetUserPassEx(p, user_ctx, user_handle, true, &password)) { - ret = False; + ret = false; } /* Try a 'short' password */ - if (!test_ChangePasswordUser2(p, user_ctx, base_acct_name, &password, samr_rand_pass(mem_ctx, 4), False)) { - ret = False; + if (!test_ChangePasswordUser2(p, user_ctx, base_acct_name, &password, samr_rand_pass(mem_ctx, 4), false)) { + ret = false; } } for (i = 0; password_fields[i]; i++) { if (!test_SetUserPass_23(p, user_ctx, user_handle, password_fields[i], &password)) { - ret = False; + ret = false; } /* check it was set right */ - if (!test_ChangePasswordUser3(p, user_ctx, base_acct_name, 0, &password, NULL, 0, False)) { - ret = False; + if (!test_ChangePasswordUser3(p, user_ctx, base_acct_name, 0, &password, NULL, 0, false)) { + ret = false; } } for (i = 0; password_fields[i]; i++) { if (!test_SetUserPass_25(p, user_ctx, user_handle, password_fields[i], &password)) { - ret = False; + ret = false; } /* check it was set right */ - if (!test_ChangePasswordUser3(p, user_ctx, base_acct_name, 0, &password, NULL, 0, False)) { - ret = False; + if (!test_ChangePasswordUser3(p, user_ctx, base_acct_name, 0, &password, NULL, 0, false)) { + ret = false; } } if (!test_SetUserPassEx(p, user_ctx, user_handle, false, &password)) { - ret = False; + ret = false; } if (!test_ChangePassword(p, user_ctx, base_acct_name, domain_handle, &password)) { - ret = False; + ret = false; } break; @@ -2081,47 +2099,47 @@ static BOOL test_user_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_alias_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_alias_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *alias_handle, const struct dom_sid *domain_sid) { - BOOL ret = True; + bool ret = true; if (!test_QuerySecurity(p, mem_ctx, alias_handle)) { - ret = False; + ret = false; } if (!test_QueryAliasInfo(p, mem_ctx, alias_handle)) { - ret = False; + ret = false; } if (!test_SetAliasInfo(p, mem_ctx, alias_handle)) { - ret = False; + ret = false; } if (!test_AddMemberToAlias(p, mem_ctx, alias_handle, domain_sid)) { - ret = False; + ret = false; } - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping MultipleMembers Alias tests against Samba4\n"); return ret; } if (!test_AddMultipleMembersToAlias(p, mem_ctx, alias_handle)) { - ret = False; + ret = false; } return ret; } -static BOOL test_DeleteUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DeleteUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *user_handle) { struct samr_DeleteUser d; NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("Testing DeleteUser\n"); d.in.user_handle = user_handle; @@ -2130,13 +2148,13 @@ static BOOL test_DeleteUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_DeleteUser(p, mem_ctx, &d); if (!NT_STATUS_IS_OK(status)) { printf("DeleteUser failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -BOOL test_DeleteUser_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_DeleteUser_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char *name) { NTSTATUS status; @@ -2161,15 +2179,15 @@ BOOL test_DeleteUser_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, goto failed; } - return True; + return true; failed: printf("DeleteUser_byname(%s) failed - %s\n", name, nt_errstr(status)); - return False; + return false; } -static BOOL test_DeleteGroup_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DeleteGroup_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char *name) { NTSTATUS status; @@ -2199,15 +2217,15 @@ static BOOL test_DeleteGroup_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, goto failed; } - return True; + return true; failed: printf("DeleteGroup_byname(%s) failed - %s\n", name, nt_errstr(status)); - return False; + return false; } -static BOOL test_DeleteAlias_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DeleteAlias_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, const char *name) { NTSTATUS status; @@ -2239,19 +2257,19 @@ static BOOL test_DeleteAlias_byname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, goto failed; } - return True; + return true; failed: printf("DeleteAlias_byname(%s) failed - %s\n", name, nt_errstr(status)); - return False; + return false; } -static BOOL test_DeleteAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DeleteAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *alias_handle) { struct samr_DeleteDomAlias d; NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("Testing DeleteAlias\n"); d.in.alias_handle = alias_handle; @@ -2260,13 +2278,13 @@ static BOOL test_DeleteAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_DeleteDomAlias(p, mem_ctx, &d); if (!NT_STATUS_IS_OK(status)) { printf("DeleteAlias failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, struct policy_handle *alias_handle, const struct dom_sid *domain_sid) @@ -2275,7 +2293,7 @@ static BOOL test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_CreateDomAlias r; struct lsa_String name; uint32_t rid; - BOOL ret = True; + bool ret = true; init_lsa_String(&name, TEST_ALIASNAME); r.in.domain_handle = domain_handle; @@ -2290,53 +2308,53 @@ static BOOL test_CreateAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { printf("Server refused create of '%s'\n", r.in.alias_name->string); - return True; + return true; } if (NT_STATUS_EQUAL(status, NT_STATUS_ALIAS_EXISTS)) { if (!test_DeleteAlias_byname(p, mem_ctx, domain_handle, r.in.alias_name->string)) { - return False; + return false; } status = dcerpc_samr_CreateDomAlias(p, mem_ctx, &r); } if (!NT_STATUS_IS_OK(status)) { printf("CreateAlias failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!test_alias_ops(p, mem_ctx, alias_handle, domain_sid)) { - ret = False; + ret = false; } return ret; } -static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *acct_name, struct policy_handle *domain_handle, char **password) { - BOOL ret = True; + bool ret = true; if (!*password) { - return False; + return false; } if (!test_ChangePasswordUser(p, mem_ctx, acct_name, domain_handle, password)) { - ret = False; + ret = false; } - if (!test_ChangePasswordUser2(p, mem_ctx, acct_name, password, 0, True)) { - ret = False; + if (!test_ChangePasswordUser2(p, mem_ctx, acct_name, password, 0, true)) { + ret = false; } if (!test_OemChangePasswordUser2(p, mem_ctx, acct_name, domain_handle, password)) { - ret = False; + ret = false; } /* test what happens when setting the old password again */ - if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, *password, 0, True)) { - ret = False; + if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, *password, 0, true)) { + ret = false; } { @@ -2347,8 +2365,8 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, memset(simple_pass, *v, sizeof(simple_pass) - 1); /* test what happens when picking a simple password */ - if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, simple_pass, 0, True)) { - ret = False; + if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, simple_pass, 0, true)) { + ret = false; } } @@ -2369,7 +2387,7 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("testing samr_QueryDomainInfo level 1\n"); status = dcerpc_samr_QueryDomainInfo(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } s.in.domain_handle = domain_handle; @@ -2389,13 +2407,13 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("testing samr_SetDomainInfo level 1\n"); status = dcerpc_samr_SetDomainInfo(p, mem_ctx, &s); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } printf("calling test_ChangePasswordUser3 with too short password\n"); - if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, len - 1, password, NULL, 0, True)) { - ret = False; + if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, len - 1, password, NULL, 0, true)) { + ret = false; } s.in.info->info1.min_password_length = len_old; @@ -2405,7 +2423,7 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("testing samr_SetDomainInfo level 1\n"); status = dcerpc_samr_SetDomainInfo(p, mem_ctx, &s); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } } @@ -2425,7 +2443,7 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupNames(p, mem_ctx, &n); if (!NT_STATUS_IS_OK(status)) { printf("LookupNames failed - %s\n", nt_errstr(status)); - return False; + return false; } r.in.domain_handle = domain_handle; @@ -2436,7 +2454,7 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenUser(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("OpenUser(%u) failed - %s\n", n.out.rids.ids[0], nt_errstr(status)); - return False; + return false; } q.in.user_handle = &user_handle; @@ -2445,31 +2463,31 @@ static BOOL test_ChangePassword(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_QueryUserInfo(p, mem_ctx, &q); if (!NT_STATUS_IS_OK(status)) { printf("QueryUserInfo failed - %s\n", nt_errstr(status)); - return False; + return false; } printf("calling test_ChangePasswordUser3 with too early password change\n"); if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL, - q.out.info->info5.last_password_change, True)) { - ret = False; + q.out.info->info5.last_password_change, true)) { + ret = false; } } /* we change passwords twice - this has the effect of verifying they were changed correctly for the final call */ - if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL, 0, True)) { - ret = False; + if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL, 0, true)) { + ret = false; } - if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL, 0, True)) { - ret = False; + if (!test_ChangePasswordUser3(p, mem_ctx, acct_name, 0, password, NULL, 0, true)) { + ret = false; } return ret; } -static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, struct policy_handle *user_handle_out, enum torture_samr_choice which_ops) @@ -2486,7 +2504,7 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, /* This call creates a 'normal' account - check that it really does */ const uint32_t acct_flags = ACB_NORMAL; struct lsa_String name; - BOOL ret = True; + bool ret = true; struct policy_handle user_handle; user_ctx = talloc_named(mem_ctx, 0, "test_CreateUser2 per-user context"); @@ -2505,20 +2523,20 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { printf("Server refused create of '%s': %s\n", r.in.account_name->string, nt_errstr(status)); talloc_free(user_ctx); - return True; + return true; } if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { if (!test_DeleteUser_byname(p, user_ctx, domain_handle, r.in.account_name->string)) { talloc_free(user_ctx); - return False; + return false; } status = dcerpc_samr_CreateUser(p, user_ctx, &r); } if (!NT_STATUS_IS_OK(status)) { talloc_free(user_ctx); printf("CreateUser failed - %s\n", nt_errstr(status)); - return False; + return false; } else { q.in.user_handle = &user_handle; q.in.level = 16; @@ -2527,19 +2545,19 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryUserInfo level %u failed - %s\n", q.in.level, nt_errstr(status)); - ret = False; + ret = false; } else { if ((q.out.info->info16.acct_flags & acct_flags) != acct_flags) { printf("QuerUserInfo level 16 failed, it returned 0x%08x when we expected flags of 0x%08x\n", q.out.info->info16.acct_flags, acct_flags); - ret = False; + ret = false; } } if (!test_user_ops(p, user_ctx, &user_handle, domain_handle, acct_flags, name.string, which_ops)) { - ret = False; + ret = false; } if (user_handle_out) { @@ -2553,7 +2571,7 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_DeleteUser(p, user_ctx, &d); if (!NT_STATUS_IS_OK(status)) { printf("DeleteUser failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } } @@ -2565,7 +2583,7 @@ static BOOL test_CreateUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, enum torture_samr_choice which_ops) { NTSTATUS status; @@ -2575,7 +2593,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle user_handle; uint32_t rid; struct lsa_String name; - BOOL ret = True; + bool ret = true; int i; struct { @@ -2627,7 +2645,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } else if (NT_STATUS_EQUAL(status, NT_STATUS_USER_EXISTS)) { if (!test_DeleteUser_byname(p, user_ctx, domain_handle, r.in.account_name->string)) { talloc_free(user_ctx); - ret = False; + ret = false; continue; } status = dcerpc_samr_CreateUser2(p, user_ctx, &r); @@ -2636,7 +2654,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(status, account_types[i].nt_status)) { printf("CreateUser2 failed gave incorrect error return - %s (should be %s)\n", nt_errstr(status), nt_errstr(account_types[i].nt_status)); - ret = False; + ret = false; } if (NT_STATUS_IS_OK(status)) { @@ -2647,34 +2665,34 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryUserInfo level %u failed - %s\n", q.in.level, nt_errstr(status)); - ret = False; + ret = false; } else { if ((q.out.info->info5.acct_flags & acct_flags) != acct_flags) { printf("QuerUserInfo level 5 failed, it returned 0x%08x when we expected flags of 0x%08x\n", q.out.info->info5.acct_flags, acct_flags); - ret = False; + ret = false; } switch (acct_flags) { case ACB_SVRTRUST: if (q.out.info->info5.primary_gid != DOMAIN_RID_DCS) { printf("QuerUserInfo level 5: DC should have had Primary Group %d, got %d\n", DOMAIN_RID_DCS, q.out.info->info5.primary_gid); - ret = False; + ret = false; } break; case ACB_WSTRUST: if (q.out.info->info5.primary_gid != DOMAIN_RID_DOMAIN_MEMBERS) { printf("QuerUserInfo level 5: Domain Member should have had Primary Group %d, got %d\n", DOMAIN_RID_DOMAIN_MEMBERS, q.out.info->info5.primary_gid); - ret = False; + ret = false; } break; case ACB_NORMAL: if (q.out.info->info5.primary_gid != DOMAIN_RID_USERS) { printf("QuerUserInfo level 5: Users should have had Primary Group %d, got %d\n", DOMAIN_RID_USERS, q.out.info->info5.primary_gid); - ret = False; + ret = false; } break; } @@ -2682,7 +2700,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!test_user_ops(p, user_ctx, &user_handle, domain_handle, acct_flags, name.string, which_ops)) { - ret = False; + ret = false; } printf("Testing DeleteUser (createuser2 test)\n"); @@ -2693,7 +2711,7 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_DeleteUser(p, user_ctx, &d); if (!NT_STATUS_IS_OK(status)) { printf("DeleteUser failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } } talloc_free(user_ctx); @@ -2702,14 +2720,14 @@ static BOOL test_CreateUser2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_QueryAliasInfo r; uint16_t levels[] = {1, 2, 3}; int i; - BOOL ret = True; + bool ret = true; for (i=0;i<ARRAY_SIZE(levels);i++) { printf("Testing QueryAliasInfo level %u\n", levels[i]); @@ -2721,21 +2739,21 @@ static BOOL test_QueryAliasInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryAliasInfo level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } } return ret; } -static BOOL test_QueryGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_QueryGroupInfo r; uint16_t levels[] = {1, 2, 3, 4, 5}; int i; - BOOL ret = True; + bool ret = true; for (i=0;i<ARRAY_SIZE(levels);i++) { printf("Testing QueryGroupInfo level %u\n", levels[i]); @@ -2747,19 +2765,19 @@ static BOOL test_QueryGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryGroupInfo level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } } return ret; } -static BOOL test_QueryGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_QueryGroupMember r; - BOOL ret = True; + bool ret = true; printf("Testing QueryGroupMember\n"); @@ -2768,14 +2786,14 @@ static BOOL test_QueryGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_QueryGroupMember(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("QueryGroupInfo failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -2784,7 +2802,7 @@ static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t levels[] = {1, 2, 3, 4}; uint16_t set_ok[] = {0, 1, 1, 1}; int i; - BOOL ret = True; + bool ret = true; for (i=0;i<ARRAY_SIZE(levels);i++) { printf("Testing QueryGroupInfo level %u\n", levels[i]); @@ -2796,7 +2814,7 @@ static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryGroupInfo level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } printf("Testing SetGroupInfo level %u\n", levels[i]); @@ -2824,14 +2842,14 @@ static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetGroupInfo level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; continue; } } else { if (!NT_STATUS_EQUAL(NT_STATUS_INVALID_INFO_CLASS, status)) { printf("SetGroupInfo level %u gave %s - should have been NT_STATUS_INVALID_INFO_CLASS\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; continue; } } @@ -2840,7 +2858,7 @@ static BOOL test_SetGroupInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -2848,7 +2866,7 @@ static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21}; int i; - BOOL ret = True; + bool ret = true; for (i=0;i<ARRAY_SIZE(levels);i++) { printf("Testing QueryUserInfo level %u\n", levels[i]); @@ -2860,14 +2878,14 @@ static BOOL test_QueryUserInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryUserInfo level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } } return ret; } -static BOOL test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -2875,7 +2893,7 @@ static BOOL test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 20, 21}; int i; - BOOL ret = True; + bool ret = true; for (i=0;i<ARRAY_SIZE(levels);i++) { printf("Testing QueryUserInfo2 level %u\n", levels[i]); @@ -2887,20 +2905,20 @@ static BOOL test_QueryUserInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryUserInfo2 level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } } return ret; } -static BOOL test_OpenUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_OpenUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint32_t rid) { NTSTATUS status; struct samr_OpenUser r; struct policy_handle user_handle; - BOOL ret = True; + bool ret = true; printf("Testing OpenUser(%u)\n", rid); @@ -2912,43 +2930,43 @@ static BOOL test_OpenUser(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenUser(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(status)); - return False; + return false; } if (!test_QuerySecurity(p, mem_ctx, &user_handle)) { - ret = False; + ret = false; } if (!test_QueryUserInfo(p, mem_ctx, &user_handle)) { - ret = False; + ret = false; } if (!test_QueryUserInfo2(p, mem_ctx, &user_handle)) { - ret = False; + ret = false; } if (!test_GetUserPwInfo(p, mem_ctx, &user_handle)) { - ret = False; + ret = false; } if (!test_GetGroupsForUser(p,mem_ctx, &user_handle)) { - ret = False; + ret = false; } if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) { - ret = False; + ret = false; } return ret; } -static BOOL test_OpenGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_OpenGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint32_t rid) { NTSTATUS status; struct samr_OpenGroup r; struct policy_handle group_handle; - BOOL ret = True; + bool ret = true; printf("Testing OpenGroup(%u)\n", rid); @@ -2960,35 +2978,35 @@ static BOOL test_OpenGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenGroup(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("OpenGroup(%u) failed - %s\n", rid, nt_errstr(status)); - return False; + return false; } if (!test_QuerySecurity(p, mem_ctx, &group_handle)) { - ret = False; + ret = false; } if (!test_QueryGroupInfo(p, mem_ctx, &group_handle)) { - ret = False; + ret = false; } if (!test_QueryGroupMember(p, mem_ctx, &group_handle)) { - ret = False; + ret = false; } if (!test_samr_handle_Close(p, mem_ctx, &group_handle)) { - ret = False; + ret = false; } return ret; } -static BOOL test_OpenAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_OpenAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint32_t rid) { NTSTATUS status; struct samr_OpenAlias r; struct policy_handle alias_handle; - BOOL ret = True; + bool ret = true; printf("Testing OpenAlias(%u)\n", rid); @@ -3000,29 +3018,29 @@ static BOOL test_OpenAlias(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenAlias(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("OpenAlias(%u) failed - %s\n", rid, nt_errstr(status)); - return False; + return false; } if (!test_QuerySecurity(p, mem_ctx, &alias_handle)) { - ret = False; + ret = false; } if (!test_QueryAliasInfo(p, mem_ctx, &alias_handle)) { - ret = False; + ret = false; } if (!test_GetMembersInAlias(p, mem_ctx, &alias_handle)) { - ret = False; + ret = false; } if (!test_samr_handle_Close(p, mem_ctx, &alias_handle)) { - ret = False; + ret = false; } return ret; } -static BOOL check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, uint32_t rid, uint32_t acct_flag_mask) { @@ -3030,7 +3048,7 @@ static BOOL check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_OpenUser r; struct samr_QueryUserInfo q; struct policy_handle user_handle; - BOOL ret = True; + bool ret = true; printf("Testing OpenUser(%u)\n", rid); @@ -3042,7 +3060,7 @@ static BOOL check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenUser(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(status)); - return False; + return false; } q.in.user_handle = &user_handle; @@ -3052,30 +3070,30 @@ static BOOL check_mask(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryUserInfo level 16 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { if ((acct_flag_mask & q.out.info->info16.acct_flags) == 0) { printf("Server failed to filter for 0x%x, allowed 0x%x (%d) on EnumDomainUsers\n", acct_flag_mask, q.out.info->info16.acct_flags, rid); - ret = False; + ret = false; } } if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) { - ret = False; + ret = false; } return ret; } -static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status = STATUS_MORE_ENTRIES; struct samr_EnumDomainUsers r; uint32_t mask, resume_handle=0; int i, mask_idx; - BOOL ret = True; + bool ret = true; struct samr_LookupNames n; struct samr_LookupRids lr ; uint32_t masks[] = {ACB_NORMAL, ACB_DOMTRUST, ACB_WSTRUST, @@ -3096,12 +3114,12 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES) && !NT_STATUS_IS_OK(status)) { printf("EnumDomainUsers failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!r.out.sam) { printf("EnumDomainUsers failed: r.out.sam unexpectedly NULL\n"); - return False; + return false; } if (r.out.sam->count == 0) { @@ -3111,10 +3129,10 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, for (i=0;i<r.out.sam->count;i++) { if (mask) { if (!check_mask(p, mem_ctx, handle, r.out.sam->entries[i].idx, mask)) { - ret = False; + ret = false; } } else if (!test_OpenUser(p, mem_ctx, handle, r.out.sam->entries[i].idx)) { - ret = False; + ret = false; } } } @@ -3129,7 +3147,7 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupNames(p, mem_ctx, &n); if (!NT_STATUS_IS_OK(status)) { printf("LookupNames failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } @@ -3143,7 +3161,7 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupRids(p, mem_ctx, &lr); if (!NT_STATUS_IS_OK(status)) { printf("LookupRids failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; @@ -3152,7 +3170,7 @@ static BOOL test_EnumDomainUsers(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, /* try blasting the server with a bunch of sync requests */ -static BOOL test_EnumDomainUsers_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_EnumDomainUsers_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -3162,9 +3180,9 @@ static BOOL test_EnumDomainUsers_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct #define ASYNC_COUNT 100 struct rpc_request *req[ASYNC_COUNT]; - if (!lp_parm_bool(-1, "torture", "dangerous", False)) { + if (!lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) { printf("samr async test disabled - enable dangerous tests to use\n"); - return True; + return true; } printf("Testing EnumDomainUsers_async\n"); @@ -3184,23 +3202,23 @@ static BOOL test_EnumDomainUsers_async(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct if (!NT_STATUS_IS_OK(status)) { printf("EnumDomainUsers[%d] failed - %s\n", i, nt_errstr(status)); - return False; + return false; } } printf("%d async requests OK\n", i); - return True; + return true; } -static BOOL test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_EnumDomainGroups r; uint32_t resume_handle=0; int i; - BOOL ret = True; + bool ret = true; printf("Testing EnumDomainGroups\n"); @@ -3212,30 +3230,30 @@ static BOOL test_EnumDomainGroups(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_EnumDomainGroups(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("EnumDomainGroups failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!r.out.sam) { - return False; + return false; } for (i=0;i<r.out.sam->count;i++) { if (!test_OpenGroup(p, mem_ctx, handle, r.out.sam->entries[i].idx)) { - ret = False; + ret = false; } } return ret; } -static BOOL test_EnumDomainAliases(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_EnumDomainAliases(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_EnumDomainAliases r; uint32_t resume_handle=0; int i; - BOOL ret = True; + bool ret = true; printf("Testing EnumDomainAliases\n"); @@ -3247,28 +3265,28 @@ static BOOL test_EnumDomainAliases(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_EnumDomainAliases(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("EnumDomainAliases failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!r.out.sam) { - return False; + return false; } for (i=0;i<r.out.sam->count;i++) { if (!test_OpenAlias(p, mem_ctx, handle, r.out.sam->entries[i].idx)) { - ret = False; + ret = false; } } return ret; } -static BOOL test_GetDisplayEnumerationIndex(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetDisplayEnumerationIndex(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_GetDisplayEnumerationIndex r; - BOOL ret = True; + bool ret = true; uint16_t levels[] = {1, 2, 3, 4, 5}; uint16_t ok_lvl[] = {1, 1, 1, 0, 0}; int i; @@ -3287,7 +3305,7 @@ static BOOL test_GetDisplayEnumerationIndex(struct dcerpc_pipe *p, TALLOC_CTX *m !NT_STATUS_EQUAL(NT_STATUS_NO_MORE_ENTRIES, status)) { printf("GetDisplayEnumerationIndex level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } init_lsa_String(&r.in.name, "zzzzzzzz"); @@ -3297,19 +3315,19 @@ static BOOL test_GetDisplayEnumerationIndex(struct dcerpc_pipe *p, TALLOC_CTX *m if (ok_lvl[i] && !NT_STATUS_EQUAL(NT_STATUS_NO_MORE_ENTRIES, status)) { printf("GetDisplayEnumerationIndex level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } } return ret; } -static BOOL test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_GetDisplayEnumerationIndex2 r; - BOOL ret = True; + bool ret = true; uint16_t levels[] = {1, 2, 3, 4, 5}; uint16_t ok_lvl[] = {1, 1, 1, 0, 0}; int i; @@ -3327,7 +3345,7 @@ static BOOL test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX * !NT_STATUS_EQUAL(NT_STATUS_NO_MORE_ENTRIES, status)) { printf("GetDisplayEnumerationIndex2 level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } init_lsa_String(&r.in.name, "zzzzzzzz"); @@ -3336,7 +3354,7 @@ static BOOL test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX * if (ok_lvl[i] && !NT_STATUS_EQUAL(NT_STATUS_NO_MORE_ENTRIES, status)) { printf("GetDisplayEnumerationIndex2 level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } } @@ -3349,23 +3367,23 @@ static BOOL test_GetDisplayEnumerationIndex2(struct dcerpc_pipe *p, TALLOC_CTX * } else if ((s1.string && !s2.string) || (s2.string && !s1.string) || strcmp(s1.string, s2.string)) { \ printf("%s mismatch for %s: %s != %s (%s)\n", \ #s1, user.string, s1.string, s2.string, __location__); \ - ret = False; \ + ret = false; \ } #define INT_EQUAL_QUERY(s1, s2, user) \ if (s1 != s2) { \ - printf("%s mismatch for %s: 0x%x != 0x%x (%s)\n", \ - #s1, user.string, (unsigned int)s1, (unsigned int)s2, __location__); \ - ret = False; \ + printf("%s mismatch for %s: 0x%llx != 0x%llx (%s)\n", \ + #s1, user.string, (unsigned long long)s1, (unsigned long long)s2, __location__); \ + ret = false; \ } -static BOOL test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_QueryDisplayInfo *querydisplayinfo, bool *seen_testuser) { struct samr_OpenUser r; struct samr_QueryUserInfo q; struct policy_handle user_handle; - int i, ret = True; + int i, ret = true; NTSTATUS status; r.in.domain_handle = querydisplayinfo->in.domain_handle; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -3399,7 +3417,7 @@ static BOOL test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct status = dcerpc_samr_OpenUser(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("OpenUser(%u) failed - %s\n", r.in.rid, nt_errstr(status)); - return False; + return false; } } @@ -3408,7 +3426,7 @@ static BOOL test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct status = dcerpc_samr_QueryUserInfo(p, mem_ctx, &q); if (!NT_STATUS_IS_OK(status)) { printf("QueryUserInfo(%u) failed - %s\n", r.in.rid, nt_errstr(status)); - return False; + return false; } switch (querydisplayinfo->in.level) { @@ -3448,26 +3466,26 @@ static BOOL test_each_DisplayInfo_user(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct q.out.info->info21.account_name.string, querydisplayinfo->out.info.info2.entries[i].acct_flags, q.out.info->info21.acct_flags); - return False; + return false; } break; } if (!test_samr_handle_Close(p, mem_ctx, &user_handle)) { - return False; + return false; } } return ret; } -static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_QueryDisplayInfo r; struct samr_QueryDomainInfo dom_info; - BOOL ret = True; + bool ret = true; uint16_t levels[] = {1, 2, 3, 4, 5}; int i; bool seen_testuser = false; @@ -3487,18 +3505,18 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES) && !NT_STATUS_IS_OK(status)) { printf("QueryDisplayInfo level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } switch (r.in.level) { case 1: if (!test_each_DisplayInfo_user(p, mem_ctx, &r, &seen_testuser)) { - ret = False; + ret = false; } r.in.start_idx += r.out.info.info1.count; break; case 2: if (!test_each_DisplayInfo_user(p, mem_ctx, &r, NULL)) { - ret = False; + ret = false; } r.in.start_idx += r.out.info.info2.count; break; @@ -3520,7 +3538,7 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryDomainInfo level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; break; } switch (r.in.level) { @@ -3530,14 +3548,14 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("QueryDomainInfo indicates that QueryDisplayInfo returned more users (%d/%d) than the domain %s is said to contain!\n", r.in.start_idx, dom_info.out.info->info2.num_groups, dom_info.out.info->info2.domain_name.string); - ret = False; + ret = false; } if (!seen_testuser) { struct policy_handle user_handle; if (NT_STATUS_IS_OK(test_OpenUser_byname(p, mem_ctx, handle, TEST_ACCOUNT_NAME, &user_handle))) { printf("Didn't find test user " TEST_ACCOUNT_NAME " in enumeration of %s\n", dom_info.out.info->info2.domain_name.string); - ret = False; + ret = false; test_samr_handle_Close(p, mem_ctx, &user_handle); } } @@ -3548,7 +3566,7 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("QueryDomainInfo indicates that QueryDisplayInfo didn't return all (%d/%d) the groups in %s\n", r.in.start_idx, dom_info.out.info->info2.num_groups, dom_info.out.info->info2.domain_name.string); - ret = False; + ret = false; } break; @@ -3559,12 +3577,12 @@ static BOOL test_QueryDisplayInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_QueryDisplayInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryDisplayInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_QueryDisplayInfo2 r; - BOOL ret = True; + bool ret = true; uint16_t levels[] = {1, 2, 3, 4, 5}; int i; @@ -3581,19 +3599,19 @@ static BOOL test_QueryDisplayInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryDisplayInfo2 level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } } return ret; } -static BOOL test_QueryDisplayInfo3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryDisplayInfo3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_QueryDisplayInfo3 r; - BOOL ret = True; + bool ret = true; uint16_t levels[] = {1, 2, 3, 4, 5}; int i; @@ -3610,7 +3628,7 @@ static BOOL test_QueryDisplayInfo3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryDisplayInfo3 level %u failed - %s\n", levels[i], nt_errstr(status)); - ret = False; + ret = false; } } @@ -3618,12 +3636,12 @@ static BOOL test_QueryDisplayInfo3(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -static BOOL test_QueryDisplayInfo_continue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryDisplayInfo_continue(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_QueryDisplayInfo r; - BOOL ret = True; + bool ret = true; printf("Testing QueryDisplayInfo continuation\n"); @@ -3647,7 +3665,7 @@ static BOOL test_QueryDisplayInfo_continue(struct dcerpc_pipe *p, TALLOC_CTX *me !NT_STATUS_IS_OK(status)) { printf("QueryDisplayInfo level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; break; } r.in.start_idx++; @@ -3658,7 +3676,7 @@ static BOOL test_QueryDisplayInfo_continue(struct dcerpc_pipe *p, TALLOC_CTX *me return ret; } -static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -3667,7 +3685,7 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13}; uint16_t set_ok[] = {1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0}; int i; - BOOL ret = True; + bool ret = true; const char *domain_comment = talloc_asprintf(mem_ctx, "Tortured by Samba4 RPC-SAMR: %s", timestring(mem_ctx, time(NULL))); @@ -3681,7 +3699,7 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetDomainInfo level %u (set comment) failed - %s\n", r.in.level, nt_errstr(status)); - return False; + return false; } for (i=0;i<ARRAY_SIZE(levels);i++) { @@ -3694,7 +3712,7 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryDomainInfo level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; continue; } @@ -3703,12 +3721,12 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (strcmp(r.out.info->info2.comment.string, domain_comment) != 0) { printf("QueryDomainInfo level %u returned different comment (%s, expected %s)\n", levels[i], r.out.info->info2.comment.string, domain_comment); - ret = False; + ret = false; } if (!r.out.info->info2.primary.string) { printf("QueryDomainInfo level %u returned no PDC name\n", levels[i]); - ret = False; + ret = false; } else if (r.out.info->info2.role == SAMR_ROLE_DOMAIN_PDC) { if (dcerpc_server_name(p) && strcasecmp_m(dcerpc_server_name(p), r.out.info->info2.primary.string) != 0) { printf("QueryDomainInfo level %u returned different PDC name (%s) compared to server name (%s), despite claiming to be the PDC\n", @@ -3720,21 +3738,21 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (strcmp(r.out.info->info4.comment.string, domain_comment) != 0) { printf("QueryDomainInfo level %u returned different comment (%s, expected %s)\n", levels[i], r.out.info->info4.comment.string, domain_comment); - ret = False; + ret = false; } break; case 6: if (!r.out.info->info6.primary.string) { printf("QueryDomainInfo level %u returned no PDC name\n", levels[i]); - ret = False; + ret = false; } break; case 11: if (strcmp(r.out.info->info11.info2.comment.string, domain_comment) != 0) { printf("QueryDomainInfo level %u returned different comment (%s, expected %s)\n", levels[i], r.out.info->info11.info2.comment.string, domain_comment); - ret = False; + ret = false; } break; } @@ -3750,14 +3768,14 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("SetDomainInfo level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; continue; } } else { if (!NT_STATUS_EQUAL(NT_STATUS_INVALID_INFO_CLASS, status)) { printf("SetDomainInfo level %u gave %s - should have been NT_STATUS_INVALID_INFO_CLASS\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; continue; } } @@ -3766,7 +3784,7 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryDomainInfo level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; continue; } } @@ -3775,14 +3793,14 @@ static BOOL test_QueryDomainInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -static BOOL test_QueryDomainInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_QueryDomainInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; struct samr_QueryDomainInfo2 r; uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13}; int i; - BOOL ret = True; + bool ret = true; for (i=0;i<ARRAY_SIZE(levels);i++) { printf("Testing QueryDomainInfo2 level %u\n", levels[i]); @@ -3794,17 +3812,17 @@ static BOOL test_QueryDomainInfo2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryDomainInfo2 level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; + ret = false; continue; } } - return True; + return true; } /* Test whether querydispinfo level 5 and enumdomgroups return the same set of group names. */ -static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { struct samr_EnumDomainGroups q1; @@ -3812,7 +3830,7 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, NTSTATUS status; uint32_t resume_handle=0; int i; - BOOL ret = True; + bool ret = true; int num_names = 0; const char **names = NULL; @@ -3841,11 +3859,11 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("EnumDomainGroups failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!q1.out.sam) { - return False; + return false; } q2.in.domain_handle = handle; @@ -3865,14 +3883,14 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, for (i=0; i<q2.out.info.info5.count; i++) { int j; const char *name = q2.out.info.info5.entries[i].account_name.string; - BOOL found = False; + bool found = false; for (j=0; j<num_names; j++) { if (names[j] == NULL) continue; /* Hmm. No strequal in samba4 */ if (strequal(names[j], name)) { names[j] = NULL; - found = True; + found = true; break; } } @@ -3880,7 +3898,7 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!found) { printf("QueryDisplayInfo gave name [%s] that EnumDomainGroups did not\n", name); - ret = False; + ret = false; } } q2.in.start_idx += q2.out.info.info5.count; @@ -3889,26 +3907,26 @@ static BOOL test_GroupList(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { printf("QueryDisplayInfo level 5 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } for (i=0; i<num_names; i++) { if (names[i] != NULL) { printf("EnumDomainGroups gave name [%s] that QueryDisplayInfo did not\n", names[i]); - ret = False; + ret = false; } } return ret; } -static BOOL test_DeleteDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DeleteDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *group_handle) { struct samr_DeleteDomainGroup d; NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("Testing DeleteDomainGroup\n"); @@ -3918,18 +3936,18 @@ static BOOL test_DeleteDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_DeleteDomainGroup(p, mem_ctx, &d); if (!NT_STATUS_IS_OK(status)) { printf("DeleteDomainGroup failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_TestPrivateFunctionsDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_TestPrivateFunctionsDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { struct samr_TestPrivateFunctionsDomain r; NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("Testing TestPrivateFunctionsDomain\n"); @@ -3938,19 +3956,19 @@ static BOOL test_TestPrivateFunctionsDomain(struct dcerpc_pipe *p, TALLOC_CTX *m status = dcerpc_samr_TestPrivateFunctionsDomain(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(NT_STATUS_NOT_IMPLEMENTED, status)) { printf("TestPrivateFunctionsDomain failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } return ret; } -static BOOL test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct dom_sid *domain_sid, struct policy_handle *domain_handle) { struct samr_RidToSid r; NTSTATUS status; - BOOL ret = True; + bool ret = true; struct dom_sid *calc_sid; int rids[] = { 0, 42, 512, 10200 }; int i; @@ -3966,7 +3984,7 @@ static BOOL test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_RidToSid(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("RidToSid for %d failed - %s\n", rids[i], nt_errstr(status)); - ret = False; + ret = false; } else { calc_sid = dom_sid_add_rid(calc_sid, calc_sid, rids[i]); @@ -3974,7 +3992,7 @@ static BOOL test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("RidToSid for %d failed - got %s, expected %s\n", rids[i], dom_sid_string(mem_ctx, r.out.sid), dom_sid_string(mem_ctx, calc_sid)); - ret = False; + ret = false; } } } @@ -3982,12 +4000,12 @@ static BOOL test_RidToSid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_GetBootKeyInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetBootKeyInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { struct samr_GetBootKeyInformation r; NTSTATUS status; - BOOL ret = True; + bool ret = true; printf("Testing GetBootKeyInformation\n"); @@ -4002,7 +4020,7 @@ static BOOL test_GetBootKeyInformation(struct dcerpc_pipe *p, TALLOC_CTX *mem_ct return ret; } -static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, struct policy_handle *group_handle) { @@ -4011,13 +4029,13 @@ static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_DeleteGroupMember d; struct samr_QueryGroupMember q; struct samr_SetMemberAttributesOfGroup s; - BOOL ret = True; + bool ret = true; uint32_t rid; status = test_LookupName(p, mem_ctx, domain_handle, TEST_ACCOUNT_NAME, &rid); if (!NT_STATUS_IS_OK(status)) { printf("test_AddGroupMember looking up name " TEST_ACCOUNT_NAME " failed - %s\n", nt_errstr(status)); - return False; + return false; } r.in.group_handle = group_handle; @@ -4033,23 +4051,23 @@ static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_EQUAL(NT_STATUS_MEMBER_NOT_IN_GROUP, status)) { printf("DeleteGroupMember gave %s - should be NT_STATUS_MEMBER_NOT_IN_GROUP\n", nt_errstr(status)); - return False; + return false; } status = dcerpc_samr_AddGroupMember(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("AddGroupMember failed - %s\n", nt_errstr(status)); - return False; + return false; } status = dcerpc_samr_AddGroupMember(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(NT_STATUS_MEMBER_IN_GROUP, status)) { printf("AddGroupMember gave %s - should be NT_STATUS_MEMBER_IN_GROUP\n", nt_errstr(status)); - return False; + return false; } - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping SetMemberAttributesOfGroup test against Samba4\n"); } else { /* this one is quite strange. I am using random inputs in the @@ -4062,7 +4080,7 @@ static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_SetMemberAttributesOfGroup(p, mem_ctx, &s); if (!NT_STATUS_IS_OK(status)) { printf("SetMemberAttributesOfGroup failed - %s\n", nt_errstr(status)); - return False; + return false; } } @@ -4071,33 +4089,33 @@ static BOOL test_AddGroupMember(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_QueryGroupMember(p, mem_ctx, &q); if (!NT_STATUS_IS_OK(status)) { printf("QueryGroupMember failed - %s\n", nt_errstr(status)); - return False; + return false; } status = dcerpc_samr_DeleteGroupMember(p, mem_ctx, &d); if (!NT_STATUS_IS_OK(status)) { printf("DeleteGroupMember failed - %s\n", nt_errstr(status)); - return False; + return false; } status = dcerpc_samr_AddGroupMember(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("AddGroupMember failed - %s\n", nt_errstr(status)); - return False; + return false; } return ret; } -static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle, struct policy_handle *group_handle) { NTSTATUS status; struct samr_CreateDomainGroup r; uint32_t rid; struct lsa_String name; - BOOL ret = True; + bool ret = true; init_lsa_String(&name, TEST_GROUPNAME); @@ -4114,7 +4132,7 @@ static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { printf("Server refused create of '%s'\n", r.in.name->string); ZERO_STRUCTP(group_handle); - return True; + return true; } if (NT_STATUS_EQUAL(status, NT_STATUS_GROUP_EXISTS)) { @@ -4122,7 +4140,7 @@ static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("CreateDomainGroup failed: Could not delete domain group %s - %s\n", r.in.name->string, nt_errstr(status)); - return False; + return false; } status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r); } @@ -4131,22 +4149,22 @@ static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("CreateDomainGroup failed: Could not delete user %s - %s\n", r.in.name->string, nt_errstr(status)); - return False; + return false; } status = dcerpc_samr_CreateDomainGroup(p, mem_ctx, &r); } if (!NT_STATUS_IS_OK(status)) { printf("CreateDomainGroup failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!test_AddGroupMember(p, mem_ctx, domain_handle, group_handle)) { printf("CreateDomainGroup failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } if (!test_SetGroupInfo(p, mem_ctx, group_handle)) { - ret = False; + ret = false; } return ret; @@ -4156,7 +4174,7 @@ static BOOL test_CreateDomainGroup(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, /* its not totally clear what this does. It seems to accept any sid you like. */ -static BOOL test_RemoveMemberFromForeignDomain(struct dcerpc_pipe *p, +static bool test_RemoveMemberFromForeignDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *domain_handle) { @@ -4169,18 +4187,18 @@ static BOOL test_RemoveMemberFromForeignDomain(struct dcerpc_pipe *p, status = dcerpc_samr_RemoveMemberFromForeignDomain(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("RemoveMemberFromForeignDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } - return True; + return true; } -static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle); -static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, struct dom_sid *sid, enum torture_samr_choice which_ops) { @@ -4190,7 +4208,7 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle alias_handle; struct policy_handle user_handle; struct policy_handle group_handle; - BOOL ret = True; + bool ret = true; ZERO_STRUCT(alias_handle); ZERO_STRUCT(user_handle); @@ -4207,7 +4225,7 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_OpenDomain(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("OpenDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } /* run the domain tests with the main handle closed - this tests @@ -4238,7 +4256,7 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ret &= test_QueryDisplayInfo3(p, mem_ctx, &domain_handle); ret &= test_QueryDisplayInfo_continue(p, mem_ctx, &domain_handle); - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { printf("skipping GetDisplayEnumerationIndex test against Samba4\n"); } else { ret &= test_GetDisplayEnumerationIndex(p, mem_ctx, &domain_handle); @@ -4253,17 +4271,17 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!policy_handle_empty(&user_handle) && !test_DeleteUser(p, mem_ctx, &user_handle)) { - ret = False; + ret = false; } if (!policy_handle_empty(&alias_handle) && !test_DeleteAlias(p, mem_ctx, &alias_handle)) { - ret = False; + ret = false; } if (!policy_handle_empty(&group_handle) && !test_DeleteDomainGroup(p, mem_ctx, &group_handle)) { - ret = False; + ret = false; } ret &= test_samr_handle_Close(p, mem_ctx, &domain_handle); @@ -4278,7 +4296,7 @@ static BOOL test_OpenDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, return ret; } -static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, const char *domain, enum torture_samr_choice which_ops) { @@ -4286,7 +4304,7 @@ static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_LookupDomain r; struct lsa_String n1; struct lsa_String n2; - BOOL ret = True; + bool ret = true; printf("Testing LookupDomain(%s)\n", domain); @@ -4298,7 +4316,7 @@ static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupDomain(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(NT_STATUS_INVALID_PARAMETER, status)) { printf("failed: LookupDomain expected NT_STATUS_INVALID_PARAMETER - %s\n", nt_errstr(status)); - ret = False; + ret = false; } init_lsa_String(&n2, "xxNODOMAINxx"); @@ -4306,7 +4324,7 @@ static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupDomain(p, mem_ctx, &r); if (!NT_STATUS_EQUAL(NT_STATUS_NO_SUCH_DOMAIN, status)) { printf("failed: LookupDomain expected NT_STATUS_NO_SUCH_DOMAIN - %s\n", nt_errstr(status)); - ret = False; + ret = false; } r.in.connect_handle = handle; @@ -4317,29 +4335,29 @@ static BOOL test_LookupDomain(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_LookupDomain(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("LookupDomain failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } if (!test_GetDomPwInfo(p, mem_ctx, &n1)) { - ret = False; + ret = false; } if (!test_OpenDomain(p, mem_ctx, handle, r.out.sid, which_ops)) { - ret = False; + ret = false; } return ret; } -static BOOL test_EnumDomains(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_EnumDomains(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle, enum torture_samr_choice which_ops) { NTSTATUS status; struct samr_EnumDomains r; uint32_t resume_handle = 0; int i; - BOOL ret = True; + bool ret = true; r.in.connect_handle = handle; r.in.resume_handle = &resume_handle; @@ -4349,31 +4367,31 @@ static BOOL test_EnumDomains(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_EnumDomains(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("EnumDomains failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!r.out.sam) { - return False; + return false; } for (i=0;i<r.out.sam->count;i++) { if (!test_LookupDomain(p, mem_ctx, handle, r.out.sam->entries[i].name.string, which_ops)) { - ret = False; + ret = false; } } status = dcerpc_samr_EnumDomains(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("EnumDomains failed - %s\n", nt_errstr(status)); - return False; + return false; } return ret; } -static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct policy_handle *handle) { NTSTATUS status; @@ -4384,7 +4402,7 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct samr_Connect5 r5; union samr_ConnectInfo info; struct policy_handle h; - BOOL ret = True, got_handle = False; + bool ret = true, got_handle = false; printf("testing samr_Connect\n"); @@ -4395,9 +4413,9 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Connect(p, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("Connect failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { - got_handle = True; + got_handle = true; *handle = h; } @@ -4410,12 +4428,12 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Connect2(p, mem_ctx, &r2); if (!NT_STATUS_IS_OK(status)) { printf("Connect2 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { if (got_handle) { test_samr_handle_Close(p, mem_ctx, handle); } - got_handle = True; + got_handle = true; *handle = h; } @@ -4429,12 +4447,12 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Connect3(p, mem_ctx, &r3); if (!NT_STATUS_IS_OK(status)) { printf("Connect3 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { if (got_handle) { test_samr_handle_Close(p, mem_ctx, handle); } - got_handle = True; + got_handle = true; *handle = h; } @@ -4448,12 +4466,12 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Connect4(p, mem_ctx, &r4); if (!NT_STATUS_IS_OK(status)) { printf("Connect4 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { if (got_handle) { test_samr_handle_Close(p, mem_ctx, handle); } - got_handle = True; + got_handle = true; *handle = h; } @@ -4472,12 +4490,12 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, status = dcerpc_samr_Connect5(p, mem_ctx, &r5); if (!NT_STATUS_IS_OK(status)) { printf("Connect5 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; } else { if (got_handle) { test_samr_handle_Close(p, mem_ctx, handle); } - got_handle = True; + got_handle = true; *handle = h; } @@ -4485,16 +4503,16 @@ static BOOL test_Connect(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } -BOOL torture_rpc_samr(struct torture_context *torture) +bool torture_rpc_samr(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - BOOL ret = True; + bool ret = true; struct policy_handle handle; status = torture_rpc_connection(torture, &p, &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } ret &= test_Connect(p, torture, &handle); @@ -4513,16 +4531,16 @@ BOOL torture_rpc_samr(struct torture_context *torture) } -BOOL torture_rpc_samr_users(struct torture_context *torture) +bool torture_rpc_samr_users(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - BOOL ret = True; + bool ret = true; struct policy_handle handle; status = torture_rpc_connection(torture, &p, &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } ret &= test_Connect(p, torture, &handle); @@ -4541,16 +4559,16 @@ BOOL torture_rpc_samr_users(struct torture_context *torture) } -BOOL torture_rpc_samr_passwords(struct torture_context *torture) +bool torture_rpc_samr_passwords(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - BOOL ret = True; + bool ret = true; struct policy_handle handle; status = torture_rpc_connection(torture, &p, &ndr_table_samr); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } ret &= test_Connect(p, torture, &handle); diff --git a/source4/torture/rpc/samr_accessmask.c b/source4/torture/rpc/samr_accessmask.c new file mode 100644 index 0000000000..c444187cfc --- /dev/null +++ b/source4/torture/rpc/samr_accessmask.c @@ -0,0 +1,658 @@ +/* + Unix SMB/CIFS implementation. + test suite for accessmasks on the SAMR pipe + + Copyright (C) Ronnie Sahlberg 2007 + + 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 "torture/torture.h" +#include "librpc/gen_ndr/ndr_samr_c.h" +#include "torture/rpc/rpc.h" +#include "param/param.h" +#include "libcli/security/security.h" +#include "librpc/gen_ndr/ndr_security.h" + + +/* test user created to test the ACLs associated to SAMR objects */ +#define TEST_USER_NAME "samr_testuser" + + +static NTSTATUS torture_samr_Close(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *h) +{ + NTSTATUS status; + struct samr_Close cl; + + cl.in.handle = h; + cl.out.handle = h; + status = dcerpc_samr_Close(p, tctx, &cl); + + return status; +} + +static NTSTATUS torture_samr_Connect5(struct torture_context *tctx, + struct dcerpc_pipe *p, + uint32_t mask, struct policy_handle *h) +{ + NTSTATUS status; + struct samr_Connect5 r5; + union samr_ConnectInfo info; + + info.info1.unknown1 = 0; + info.info1.unknown2 = 0; + r5.in.system_name = ""; + r5.in.level = 1; + r5.in.info = &info; + r5.out.info = &info; + r5.out.connect_handle = h; + r5.in.access_mask = mask; + + status = dcerpc_samr_Connect5(p, tctx, &r5); + + return status; +} + +/* check which bits in accessmask allows us to connect to the server */ +static bool test_samr_accessmask_Connect5(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + NTSTATUS status; + struct policy_handle h; + int i; + uint32_t mask; + + printf("testing which bits in accessmask allows us to connect\n"); + mask = 1; + for (i=0;i<33;i++) { + printf("testing Connect5 with access mask 0x%08x", mask); + status = torture_samr_Connect5(tctx, p, mask, &h); + mask <<= 1; + + switch (i) { + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + case 13: + case 14: + case 15: + case 20: + case 21: + case 22: + case 23: + case 26: + case 27: + printf(" expecting to fail"); + /* of only one of these bits are set we expect to + fail by default + */ + if(!NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) { + printf("Connect5 failed - %s\n", nt_errstr(status)); + return false; + } + break; + default: + /* these bits set are expected to succeed by default */ + if (!NT_STATUS_IS_OK(status)) { + printf("Connect5 failed - %s\n", nt_errstr(status)); + return false; + } + + status = torture_samr_Close(tctx, p, &h); + if (!NT_STATUS_IS_OK(status)) { + printf("Close failed - %s\n", nt_errstr(status)); + return false; + } + break; + } + printf(" OK\n"); + } + + return true; +} + +/* check which bits in accessmask allows us to EnumDomains() + by default we must specify at least one of : + SAMR/EnumDomains + Maximum + GenericAll + GenericRead + in the access mask to Connect5() in order to be allowed to perform + EnumDomains() on the policy handle returned from Connect5() +*/ +static bool test_samr_accessmask_EnumDomains(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + NTSTATUS status; + struct samr_EnumDomains ed; + struct policy_handle ch; + int i; + uint32_t mask; + uint32_t resume_handle = 0; + + printf("testing which bits in Connect5 accessmask allows us to EnumDomains\n"); + mask = 1; + for (i=0;i<33;i++) { + printf("testing Connect5/EnumDomains with access mask 0x%08x", mask); + status = torture_samr_Connect5(tctx, p, mask, &ch); + mask <<= 1; + + switch (i) { + case 4: /* SAMR/EnumDomains */ + case 25: /* Maximum */ + case 28: /* GenericAll */ + case 31: /* GenericRead */ + /* these bits set are expected to succeed by default */ + if (!NT_STATUS_IS_OK(status)) { + printf("Connect5 failed - %s\n", nt_errstr(status)); + return false; + } + + ed.in.connect_handle = &ch; + ed.in.resume_handle = &resume_handle; + ed.in.buf_size = (uint32_t)-1; + ed.out.resume_handle = &resume_handle; + + status = dcerpc_samr_EnumDomains(p, tctx, &ed); + if (!NT_STATUS_IS_OK(status)) { + printf("EnumDomains failed - %s\n", nt_errstr(status)); + return false; + } + + status = torture_samr_Close(tctx, p, &ch); + if (!NT_STATUS_IS_OK(status)) { + printf("Close failed - %s\n", nt_errstr(status)); + return false; + } + break; + default: + printf(" expecting to fail"); + + if (!NT_STATUS_IS_OK(status)) { + printf(" OK\n"); + continue; + } + + ed.in.connect_handle = &ch; + ed.in.resume_handle = &resume_handle; + ed.in.buf_size = (uint32_t)-1; + ed.out.resume_handle = &resume_handle; + + status = dcerpc_samr_EnumDomains(p, tctx, &ed); + if(!NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) { + printf("EnumDomains failed - %s\n", nt_errstr(status)); + return false; + } + + status = torture_samr_Close(tctx, p, &ch); + if (!NT_STATUS_IS_OK(status)) { + printf("Close failed - %s\n", nt_errstr(status)); + return false; + } + break; + } + printf(" OK\n"); + } + + return true; +} + + +/* + * test how ACLs affect how/if a user can connect to the SAMR service + * + * samr_SetSecurity() returns SUCCESS when changing the ACL for + * a policy handle got from Connect5() but the ACL is not changed on + * the server + */ +static bool test_samr_connect_user_acl(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *test_credentials, + const struct dom_sid *test_sid) + +{ + NTSTATUS status; + struct policy_handle ch; + struct policy_handle uch; + struct samr_QuerySecurity qs; + struct samr_SetSecurity ss; + struct security_ace ace; + struct security_descriptor *sd; + struct sec_desc_buf sdb; + bool ret = true; + int sd_size; + struct dcerpc_pipe *test_p; + const char *binding = torture_setting_string(tctx, "binding", NULL); + + printf("testing ACLs to allow/prevent users to connect to SAMR"); + + /* connect to SAMR */ + status = torture_samr_Connect5(tctx, p, SEC_FLAG_MAXIMUM_ALLOWED, &ch); + if (!NT_STATUS_IS_OK(status)) { + printf("Connect5 failed - %s\n", nt_errstr(status)); + return false; + } + + + /* get the current ACL for the SAMR policy handle */ + qs.in.handle = &ch; + qs.in.sec_info = SECINFO_DACL; + status = dcerpc_samr_QuerySecurity(p, tctx, &qs); + if (!NT_STATUS_IS_OK(status)) { + printf("QuerySecurity failed - %s\n", nt_errstr(status)); + ret = false; + } + + /* how big is the security descriptor? */ + sd_size = qs.out.sdbuf->sd_size; + + + /* add an ACE to the security descriptor to deny the user the + * 'connect to server' right + */ + sd = qs.out.sdbuf->sd; + ace.type = SEC_ACE_TYPE_ACCESS_DENIED; + ace.flags = 0; + ace.access_mask = SAMR_ACCESS_CONNECT_TO_SERVER; + ace.trustee = *test_sid; + status = security_descriptor_dacl_add(sd, &ace); + if (!NT_STATUS_IS_OK(status)) { + printf("Failed to add ACE to security descriptor\n"); + ret = false; + } + ss.in.handle = &ch; + ss.in.sec_info = SECINFO_DACL; + ss.in.sdbuf = &sdb; + sdb.sd = sd; + status = dcerpc_samr_SetSecurity(p, tctx, &ss); + if (!NT_STATUS_IS_OK(status)) { + printf("SetSecurity failed - %s\n", nt_errstr(status)); + ret = false; + } + + + /* Try to connect as the test user */ + status = dcerpc_pipe_connect(tctx, + &test_p, binding, &ndr_table_samr, + test_credentials, NULL); + /* connect to SAMR as the user */ + status = torture_samr_Connect5(tctx, test_p, SEC_FLAG_MAXIMUM_ALLOWED, &uch); + if (!NT_STATUS_IS_OK(status)) { + printf("Connect5 failed - %s\n", nt_errstr(status)); + return false; + } + /* disconnec the user */ + talloc_free(test_p); + if (!NT_STATUS_IS_OK(status)) { + return false; + } + + + /* read the sequrity descriptor back. it should not have changed + * eventhough samr_SetSecurity returned SUCCESS + */ + status = dcerpc_samr_QuerySecurity(p, tctx, &qs); + if (!NT_STATUS_IS_OK(status)) { + printf("QuerySecurity failed - %s\n", nt_errstr(status)); + ret = false; + } + if (sd_size != qs.out.sdbuf->sd_size) { + printf("security descriptor changed\n"); + ret = false; + } + + + status = torture_samr_Close(tctx, p, &ch); + if (!NT_STATUS_IS_OK(status)) { + printf("Close failed - %s\n", nt_errstr(status)); + ret = false; + } + + if (ret == true) { + printf(" OK\n"); + } + return ret; +} + +/* + * test if the ACLs are enforced for users. + * a normal testuser only gets the rights provided in hte ACL for + * Everyone which does not include the SAMR_ACCESS_SHUTDOWN_SERVER + * right. If the ACLs are checked when a user connects + * a testuser that requests the accessmask with only this bit set + * the connect should fail. + */ +static bool test_samr_connect_user_acl_enforced(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct cli_credentials *test_credentials, + const struct dom_sid *test_sid) + +{ + NTSTATUS status; + struct policy_handle uch; + bool ret = true; + struct dcerpc_pipe *test_p; + const char *binding = torture_setting_string(tctx, "binding", NULL); + + printf("testing if ACLs are enforced for non domain admin users when connecting to SAMR"); + + + status = dcerpc_pipe_connect(tctx, + &test_p, binding, &ndr_table_samr, + test_credentials, NULL); + + /* connect to SAMR as the user */ + status = torture_samr_Connect5(tctx, test_p, SAMR_ACCESS_SHUTDOWN_SERVER, &uch); + if (NT_STATUS_IS_OK(status)) { + printf("Connect5 failed - %s\n", nt_errstr(status)); + return false; + } + printf(" OK\n"); + + /* disconnec the user */ + talloc_free(test_p); + + return ret; +} + +/* check which bits in accessmask allows us to LookupDomain() + by default we must specify at least one of : + in the access mask to Connect5() in order to be allowed to perform + case 5: samr/opendomain + case 25: Maximum + case 28: GenericAll + case 29: GenericExecute + LookupDomain() on the policy handle returned from Connect5() +*/ +static bool test_samr_accessmask_LookupDomain(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + NTSTATUS status; + struct samr_LookupDomain ld; + struct policy_handle ch; + struct lsa_String dn; + int i; + uint32_t mask; + + printf("testing which bits in Connect5 accessmask allows us to LookupDomain\n"); + mask = 1; + for (i=0;i<33;i++) { + printf("testing Connect5/LookupDomain with access mask 0x%08x", mask); + status = torture_samr_Connect5(tctx, p, mask, &ch); + mask <<= 1; + + switch (i) { + case 5: + case 25: /* Maximum */ + case 28: /* GenericAll */ + case 29: /* GenericExecute */ + /* these bits set are expected to succeed by default */ + if (!NT_STATUS_IS_OK(status)) { + printf("Connect5 failed - %s\n", nt_errstr(status)); + return false; + } + + ld.in.connect_handle = &ch; + ld.in.domain_name = &dn; + dn.string = lp_workgroup(global_loadparm); + + status = dcerpc_samr_LookupDomain(p, tctx, &ld); + if (!NT_STATUS_IS_OK(status)) { + printf("LookupDomain failed - %s\n", nt_errstr(status)); + return false; + } + + status = torture_samr_Close(tctx, p, &ch); + if (!NT_STATUS_IS_OK(status)) { + printf("Close failed - %s\n", nt_errstr(status)); + return false; + } + break; + default: + printf(" expecting to fail"); + + if (!NT_STATUS_IS_OK(status)) { + printf(" OK\n"); + continue; + } + + ld.in.connect_handle = &ch; + ld.in.domain_name = &dn; + dn.string = lp_workgroup(global_loadparm); + + status = dcerpc_samr_LookupDomain(p, tctx, &ld); + if(!NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) { + printf("LookupDomain failed - %s\n", nt_errstr(status)); + return false; + } + + status = torture_samr_Close(tctx, p, &ch); + if (!NT_STATUS_IS_OK(status)) { + printf("Close failed - %s\n", nt_errstr(status)); + return false; + } + break; + } + printf(" OK\n"); + } + + return true; +} + +/* check which bits in accessmask allows us to OpenDomain() + by default we must specify at least one of : + samr/opendomain + Maximum + GenericAll + GenericExecute + in the access mask to Connect5() in order to be allowed to perform + OpenDomain() on the policy handle returned from Connect5() +*/ +static bool test_samr_accessmask_OpenDomain(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + NTSTATUS status; + struct samr_LookupDomain ld; + struct samr_OpenDomain od; + struct policy_handle ch; + struct policy_handle dh; + struct lsa_String dn; + int i; + uint32_t mask; + + + /* first we must grab the sid of the domain */ + status = torture_samr_Connect5(tctx, p, SEC_FLAG_MAXIMUM_ALLOWED, &ch); + if (!NT_STATUS_IS_OK(status)) { + printf("Connect5 failed - %s\n", nt_errstr(status)); + return false; + } + + ld.in.connect_handle = &ch; + ld.in.domain_name = &dn; + dn.string = lp_workgroup(global_loadparm); + status = dcerpc_samr_LookupDomain(p, tctx, &ld); + if (!NT_STATUS_IS_OK(status)) { + printf("LookupDomain failed - %s\n", nt_errstr(status)); + return false; + } + + + + printf("testing which bits in Connect5 accessmask allows us to OpenDomain\n"); + mask = 1; + for (i=0;i<33;i++) { + printf("testing Connect5/OpenDomain with access mask 0x%08x", mask); + status = torture_samr_Connect5(tctx, p, mask, &ch); + mask <<= 1; + + switch (i) { + case 5: + case 25: /* Maximum */ + case 28: /* GenericAll */ + case 29: /* GenericExecute */ + /* these bits set are expected to succeed by default */ + if (!NT_STATUS_IS_OK(status)) { + printf("Connect5 failed - %s\n", nt_errstr(status)); + return false; + } + + od.in.connect_handle = &ch; + od.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + od.in.sid = ld.out.sid; + od.out.domain_handle = &dh; + + status = dcerpc_samr_OpenDomain(p, tctx, &od); + if (!NT_STATUS_IS_OK(status)) { + printf("OpenDomain failed - %s\n", nt_errstr(status)); + return false; + } + + status = torture_samr_Close(tctx, p, &dh); + if (!NT_STATUS_IS_OK(status)) { + printf("Close failed - %s\n", nt_errstr(status)); + return false; + } + + status = torture_samr_Close(tctx, p, &ch); + if (!NT_STATUS_IS_OK(status)) { + printf("Close failed - %s\n", nt_errstr(status)); + return false; + } + break; + default: + printf(" expecting to fail"); + + if (!NT_STATUS_IS_OK(status)) { + printf(" OK\n"); + continue; + } + + status = torture_samr_Close(tctx, p, &ch); + if (!NT_STATUS_IS_OK(status)) { + printf("Close failed - %s\n", nt_errstr(status)); + return false; + } + break; + } + printf(" OK\n"); + } + + return true; +} + +static bool test_samr_connect(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + void *testuser; + const char *testuser_passwd; + struct cli_credentials *test_credentials; + bool ret = true; + const struct dom_sid *test_sid; + + /* create a test user */ + testuser = torture_create_testuser(tctx, TEST_USER_NAME, lp_workgroup(global_loadparm), + ACB_NORMAL, &testuser_passwd); + if (!testuser) { + printf("Failed to create test user\n"); + return false; + } + test_credentials = cli_credentials_init(tctx); + cli_credentials_set_workstation(test_credentials, "localhost", CRED_SPECIFIED); + cli_credentials_set_domain(test_credentials, lp_workgroup(global_loadparm), + CRED_SPECIFIED); + cli_credentials_set_username(test_credentials, TEST_USER_NAME, CRED_SPECIFIED); + cli_credentials_set_password(test_credentials, testuser_passwd, CRED_SPECIFIED); + test_sid = torture_join_user_sid(testuser); + + + /* test which bits in the accessmask to Connect5 + will allow us to connect to the server + */ + if (!test_samr_accessmask_Connect5(tctx, p)) { + ret = false; + } + + + /* test which bits in the accessmask to Connect5 will allow + * us to call EnumDomains() + */ + if (!test_samr_accessmask_EnumDomains(tctx, p)) { + ret = false; + } + + /* test which bits in the accessmask to Connect5 will allow + * us to call LookupDomain() + */ + if (!test_samr_accessmask_LookupDomain(tctx, p)) { + ret = false; + } + + + /* test which bits in the accessmask to Connect5 will allow + * us to call OpenDomain() + */ + if (!test_samr_accessmask_OpenDomain(tctx, p)) { + ret = false; + } + + + /* test if ACLs can be changed for the policy handle + * returned by Connect5 + */ + if (!test_samr_connect_user_acl(tctx, p, test_credentials, test_sid)) { + ret = false; + } + + /* test if the ACLs that are reported from the Connect5 + * policy handle is enforced. + * i.e. an ordinary user only has the same rights as Everybody + * ReadControl + * Samr/OpenDomain + * Samr/EnumDomains + * Samr/ConnectToServer + * is granted and should therefore not be able to connect when + * requesting SAMR_ACCESS_SHUTDOWN_SERVER + */ + if (!test_samr_connect_user_acl_enforced(tctx, p, test_credentials, test_sid)) { + ret = false; + } + + + + /* remove the test user */ + torture_leave_domain(testuser); + + return ret; +} + +struct torture_suite *torture_rpc_samr_accessmask(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, "SAMR_ACCESSMASK"); + struct torture_rpc_tcase *tcase; + + tcase = torture_suite_add_rpc_iface_tcase(suite, "samr", + &ndr_table_samr); + + torture_rpc_tcase_add_test(tcase, "CONNECT", test_samr_connect); + + return suite; +} diff --git a/source4/torture/rpc/samsync.c b/source4/torture/rpc/samsync.c index 358bf8791a..6f76e3b58b 100644 --- a/source4/torture/rpc/samsync.c +++ b/source4/torture/rpc/samsync.c @@ -36,6 +36,7 @@ #include "librpc/gen_ndr/ndr_lsa_c.h" #include "librpc/gen_ndr/ndr_samr_c.h" #include "librpc/gen_ndr/ndr_security.h" +#include "param/param.h" #define TEST_MACHINE_NAME "samsynctest" #define TEST_WKSTA_MACHINE_NAME "samsynctest2" @@ -67,7 +68,7 @@ static NTSTATUS test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, sizeof(ninfo.challenge)); if (nt_hash) { ninfo.nt.length = 24; - ninfo.nt.data = talloc_size(mem_ctx, 24); + ninfo.nt.data = talloc_array(mem_ctx, uint8_t, 24); SMBOWFencrypt(nt_hash->hash, ninfo.challenge, ninfo.nt.data); } else { ninfo.nt.length = 0; @@ -76,7 +77,7 @@ static NTSTATUS test_SamLogon(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (lm_hash) { ninfo.lm.length = 24; - ninfo.lm.data = talloc_size(mem_ctx, 24); + ninfo.lm.data = talloc_array(mem_ctx, uint8_t, 24); SMBOWFencrypt(lm_hash->hash, ninfo.challenge, ninfo.lm.data); } else { ninfo.lm.length = 0; @@ -222,21 +223,21 @@ static struct sec_desc_buf *samsync_query_lsa_sec_desc(TALLOC_CTX *mem_ctx, __location__, \ (long long)i1, (long long)i1, \ (long long)i2, (long long)i2);\ - ret = False;\ + ret = false;\ } \ } while (0) #define TEST_INT_EQUAL(i1, i2) do {\ if (i1 != i2) {\ printf("%s: integer mismatch: " #i1 ": 0x%08x (%d) != " #i2 ": 0x%08x (%d)\n", \ __location__, i1, i1, i2, i2); \ - ret = False;\ + ret = false;\ } \ } while (0) #define TEST_TIME_EQUAL(t1, t2) do {\ if (t1 != t2) {\ printf("%s: NTTIME mismatch: " #t1 ":%s != " #t2 ": %s\n", \ __location__, nt_time_string(mem_ctx, t1), nt_time_string(mem_ctx, t2));\ - ret = False;\ + ret = false;\ } \ } while (0) @@ -245,7 +246,7 @@ static struct sec_desc_buf *samsync_query_lsa_sec_desc(TALLOC_CTX *mem_ctx, && strcmp_safe(s1.string, s2.string) != 0) {\ printf("%s: string mismatch: " #s1 ":%s != " #s2 ": %s\n", \ __location__, s1.string, s2.string);\ - ret = False;\ + ret = false;\ } \ } while (0) @@ -253,7 +254,7 @@ static struct sec_desc_buf *samsync_query_lsa_sec_desc(TALLOC_CTX *mem_ctx, if (!dom_sid_equal(s1, s2)) {\ printf("%s: dom_sid mismatch: " #s1 ":%s != " #s2 ": %s\n", \ __location__, dom_sid_string(mem_ctx, s1), dom_sid_string(mem_ctx, s2));\ - ret = False;\ + ret = false;\ } \ } while (0) @@ -265,19 +266,19 @@ static struct sec_desc_buf *samsync_query_lsa_sec_desc(TALLOC_CTX *mem_ctx, handle); \ if (!sdbuf || !sdbuf->sd) { \ printf("Could not obtain security descriptor to match " #sd1 "\n");\ - ret = False; \ + ret = false; \ } else {\ if (!security_descriptor_mask_equal(sd1.sd, sdbuf->sd, \ ~SEC_DESC_SACL_PRESENT)) {\ printf("Security Descriptor Mismatch for %s:\n", #sd1);\ ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, "SamSync", sd1.sd);\ ndr_print_debug((ndr_print_fn_t)ndr_print_security_descriptor, "SamR", sdbuf->sd);\ - ret = False;\ + ret = false;\ }\ }\ } while (0) -static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, +static bool samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, int database_id, struct netr_DELTA_ENUM *delta) { struct netr_DELTA_DOMAIN *domain = delta->delta_union.domain; @@ -286,7 +287,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam uint16_t levels[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13}; NTSTATUS nt_status; int i; - BOOL ret = True; + bool ret = true; samsync_state->seq_num[database_id] = domain->sequence_num; @@ -300,7 +301,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam break; case SAM_DATABASE_PRIVS: printf("DOMAIN entry on privs DB!\n"); - return False; + return false; break; } @@ -311,7 +312,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam if (strcasecmp_m(samsync_state->domain_name[database_id], domain->domain_name.string) != 0) { printf("Domain has name varies!: %s != %s\n", samsync_state->domain_name[database_id], domain->domain_name.string); - return False; + return false; } } @@ -338,7 +339,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam if (!NT_STATUS_IS_OK(nt_status)) { printf("QueryDomainInfo level %u failed - %s\n", q[levels[i]].in.level, nt_errstr(nt_status)); - return False; + return false; } } @@ -366,7 +367,7 @@ static BOOL samsync_handle_domain(TALLOC_CTX *mem_ctx, struct samsync_state *sam return ret; } -static BOOL samsync_handle_policy(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, +static bool samsync_handle_policy(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, int database_id, struct netr_DELTA_ENUM *delta) { struct netr_DELTA_POLICY *policy = delta->delta_union.policy; @@ -381,23 +382,23 @@ static BOOL samsync_handle_policy(TALLOC_CTX *mem_ctx, struct samsync_state *sam if (strcasecmp_m(samsync_state->domain_name[SAM_DATABASE_DOMAIN], policy->primary_domain_name.string) != 0) { printf("PRIMARY domain has name varies between DOMAIN and POLICY!: %s != %s\n", samsync_state->domain_name[SAM_DATABASE_DOMAIN], policy->primary_domain_name.string); - return False; + return false; } } if (!dom_sid_equal(samsync_state->sid[SAM_DATABASE_DOMAIN], policy->sid)) { printf("Domain SID from POLICY (%s) does not match domain sid from SAMR (%s)\n", dom_sid_string(mem_ctx, policy->sid), dom_sid_string(mem_ctx, samsync_state->sid[SAM_DATABASE_DOMAIN])); - return False; + return false; } printf("\tsequence_nums[%d/PRIVS]=%llu\n", database_id, (long long)samsync_state->seq_num[database_id]); - return True; + return true; } -static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, +static bool samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, int database_id, struct netr_DELTA_ENUM *delta) { uint32_t rid = delta->delta_id_union.rid; @@ -410,7 +411,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy const char *domain = samsync_state->domain_name[database_id]; const char *username = user->account_name.string; NTSTATUS nt_status; - BOOL ret = True; + bool ret = true; struct samr_OpenUser r; struct samr_QueryUserInfo q; @@ -419,7 +420,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy struct samr_GetGroupsForUser getgroups; if (!samsync_state->domain_name || !samsync_state->domain_handle[database_id]) { printf("SamSync needs domain information before the users\n"); - return False; + return false; } r.in.domain_handle = samsync_state->domain_handle[database_id]; @@ -430,7 +431,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy nt_status = dcerpc_samr_OpenUser(samsync_state->p_samr, mem_ctx, &r); if (!NT_STATUS_IS_OK(nt_status)) { printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(nt_status)); - return False; + return false; } q.in.user_handle = &user_handle; @@ -442,7 +443,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy if (!NT_STATUS_IS_OK(nt_status)) { printf("QueryUserInfo level %u failed - %s\n", q.in.level, nt_errstr(nt_status)); - ret = False; + ret = false; } getgroups.in.user_handle = &user_handle; @@ -451,22 +452,22 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy if (!NT_STATUS_IS_OK(nt_status)) { printf("GetGroupsForUser failed - %s\n", nt_errstr(nt_status)); - ret = False; + ret = false; } if (!test_samr_handle_Close(samsync_state->p_samr, mem_ctx, &user_handle)) { printf("samr_handle_Close failed - %s\n", nt_errstr(nt_status)); - ret = False; + ret = false; } if (!ret) { - return False; + return false; } if (!NT_STATUS_IS_OK(nt_status)) { printf("QueryUserInfo level %u failed - %s\n", q.in.level, nt_errstr(nt_status)); - return False; + return false; } TEST_STRING_EQUAL(q.out.info->info21.account_name, user->account_name); @@ -489,7 +490,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy if (memcmp(q.out.info->info21.logon_hours.bits, user->logon_hours.bits, q.out.info->info21.logon_hours.units_per_week/8) != 0) { printf("Logon hours mismatch\n"); - ret = False; + ret = false; } } @@ -507,7 +508,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy if (user->acct_flags & ACB_PWNOEXP) { if (q.out.info->info21.acct_flags & ACB_PW_EXPIRED) { printf("ACB flags mismatch: both expired and no expiry!\n"); - ret = False; + ret = false; } if (q.out.info->info21.force_password_change != (NTTIME)0x7FFFFFFFFFFFFFFFULL) { printf("ACB flags mismatch: no password expiry, but force password change 0x%016llx (%lld) != 0x%016llx (%lld)\n", @@ -515,7 +516,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy (unsigned long long)q.out.info->info21.force_password_change, (unsigned long long)0x7FFFFFFFFFFFFFFFULL, (unsigned long long)0x7FFFFFFFFFFFFFFFULL ); - ret = False; + ret = false; } } @@ -561,7 +562,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy #if 0 dump_data(0, data.data, data.length); #endif - return False; + return false; } } @@ -584,39 +585,39 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy if (NT_STATUS_EQUAL(nt_status, NT_STATUS_ACCOUNT_DISABLED)) { if (user->acct_flags & ACB_DISABLED) { - return True; + return true; } } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT)) { if (user->acct_flags & ACB_WSTRUST) { - return True; + return true; } } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT)) { if (user->acct_flags & ACB_SVRTRUST) { - return True; + return true; } } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT)) { if (user->acct_flags & ACB_DOMTRUST) { - return True; + return true; } } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT)) { if (user->acct_flags & ACB_DOMTRUST) { - return True; + return true; } } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_ACCOUNT_LOCKED_OUT)) { if (user->acct_flags & ACB_AUTOLOCK) { - return True; + return true; } } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_PASSWORD_EXPIRED)) { if (q.out.info->info21.acct_flags & ACB_PW_EXPIRED) { - return True; + return true; } } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD)) { if (!lm_hash_p && !nt_hash_p) { - return True; + return true; } } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_PASSWORD_MUST_CHANGE)) { /* We would need to know the server's current time to test this properly */ - return True; + return true; } else if (NT_STATUS_IS_OK(nt_status)) { TEST_INT_EQUAL(user->rid, info3->base.rid); TEST_INT_EQUAL(user->primary_gid, info3->base.primary_gid); @@ -659,7 +660,7 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy if (getgroups.out.rids->count == info3->base.groups.count) { int i, j; int count = getgroups.out.rids->count; - BOOL *matched = talloc_zero_array(mem_ctx, BOOL, getgroups.out.rids->count); + bool *matched = talloc_zero_array(mem_ctx, bool, getgroups.out.rids->count); for (i = 0; i < count; i++) { for (j = 0; j < count; j++) { @@ -667,14 +668,14 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy info3->base.groups.rids[j].rid) && (getgroups.out.rids->rids[i].attributes == info3->base.groups.rids[j].attributes)) { - matched[i] = True; + matched[i] = true; } } } for (i = 0; i < getgroups.out.rids->count; i++) { - if (matched[i] == False) { - ret = False; + if (matched[i] == false) { + ret = false; printf("Could not find group RID %u found in getgroups in NETLOGON reply\n", getgroups.out.rids->rids[i].rid); } @@ -684,18 +685,18 @@ static BOOL samsync_handle_user(TALLOC_CTX *mem_ctx, struct samsync_state *samsy } else { printf("Could not validate password for user %s\\%s: %s\n", domain, username, nt_errstr(nt_status)); - return False; + return false; } - return False; + return false; } -static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, +static bool samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, int database_id, struct netr_DELTA_ENUM *delta) { uint32_t rid = delta->delta_id_union.rid; struct netr_DELTA_ALIAS *alias = delta->delta_union.alias; NTSTATUS nt_status; - BOOL ret = True; + bool ret = true; struct samr_OpenAlias r; struct samr_QueryAliasInfo q; @@ -703,7 +704,7 @@ static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *sams if (!samsync_state->domain_name || !samsync_state->domain_handle[database_id]) { printf("SamSync needs domain information before the users\n"); - return False; + return false; } r.in.domain_handle = samsync_state->domain_handle[database_id]; @@ -714,7 +715,7 @@ static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *sams nt_status = dcerpc_samr_OpenAlias(samsync_state->p_samr, mem_ctx, &r); if (!NT_STATUS_IS_OK(nt_status)) { printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(nt_status)); - return False; + return false; } q.in.alias_handle = &alias_handle; @@ -724,13 +725,13 @@ static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *sams nt_status = dcerpc_samr_QueryAliasInfo(samsync_state->p_samr, mem_ctx, &q); if (!test_samr_handle_Close(samsync_state->p_samr, mem_ctx, &alias_handle)) { - return False; + return false; } if (!NT_STATUS_IS_OK(nt_status)) { printf("QueryAliasInfo level %u failed - %s\n", q.in.level, nt_errstr(nt_status)); - return False; + return false; } TEST_STRING_EQUAL(q.out.info->all.name, alias->alias_name); @@ -738,13 +739,13 @@ static BOOL samsync_handle_alias(TALLOC_CTX *mem_ctx, struct samsync_state *sams return ret; } -static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, +static bool samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, int database_id, struct netr_DELTA_ENUM *delta) { uint32_t rid = delta->delta_id_union.rid; struct netr_DELTA_GROUP *group = delta->delta_union.group; NTSTATUS nt_status; - BOOL ret = True; + bool ret = true; struct samr_OpenGroup r; struct samr_QueryGroupInfo q; @@ -752,7 +753,7 @@ static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *sams if (!samsync_state->domain_name || !samsync_state->domain_handle[database_id]) { printf("SamSync needs domain information before the users\n"); - return False; + return false; } r.in.domain_handle = samsync_state->domain_handle[database_id]; @@ -763,7 +764,7 @@ static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *sams nt_status = dcerpc_samr_OpenGroup(samsync_state->p_samr, mem_ctx, &r); if (!NT_STATUS_IS_OK(nt_status)) { printf("OpenUser(%u) failed - %s\n", rid, nt_errstr(nt_status)); - return False; + return false; } q.in.group_handle = &group_handle; @@ -773,13 +774,13 @@ static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *sams nt_status = dcerpc_samr_QueryGroupInfo(samsync_state->p_samr, mem_ctx, &q); if (!test_samr_handle_Close(samsync_state->p_samr, mem_ctx, &group_handle)) { - return False; + return false; } if (!NT_STATUS_IS_OK(nt_status)) { printf("QueryGroupInfo level %u failed - %s\n", q.in.level, nt_errstr(nt_status)); - return False; + return false; } TEST_STRING_EQUAL(q.out.info->all.name, group->group_name); @@ -788,7 +789,7 @@ static BOOL samsync_handle_group(TALLOC_CTX *mem_ctx, struct samsync_state *sams return ret; } -static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, +static bool samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, int database_id, struct netr_DELTA_ENUM *delta) { struct netr_DELTA_SECRET *secret = delta->delta_union.secret; @@ -802,7 +803,7 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam struct lsa_DATA_BUF_PTR bufp2; NTTIME new_mtime; NTTIME old_mtime; - BOOL ret = True; + bool ret = true; DATA_BLOB lsa_blob1, lsa_blob_out, session_key; NTSTATUS status; @@ -831,7 +832,7 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam status = dcerpc_lsa_OpenSecret(samsync_state->p_lsa, mem_ctx, &o); if (!NT_STATUS_IS_OK(status)) { printf("OpenSecret failed - %s\n", nt_errstr(status)); - return False; + return false; } /* @@ -841,7 +842,7 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam status = dcerpc_fetch_session_key(samsync_state->p_lsa, &session_key); if (!NT_STATUS_IS_OK(status)) { printf("dcerpc_fetch_session_key failed - %s\n", nt_errstr(status)); - return False; + return false; } @@ -861,10 +862,10 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam status = dcerpc_lsa_QuerySecret(samsync_state->p_lsa, mem_ctx, &q); if (NT_STATUS_EQUAL(NT_STATUS_ACCESS_DENIED, status)) { /* some things are just off limits */ - return True; + return true; } else if (!NT_STATUS_IS_OK(status)) { printf("QuerySecret failed - %s\n", nt_errstr(status)); - return False; + return false; } if (q.out.old_val->buf == NULL) { @@ -876,24 +877,24 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam status = sess_decrypt_blob(mem_ctx, &lsa_blob1, &session_key, &lsa_blob_out); if (!NT_STATUS_IS_OK(status)) { printf("Failed to decrypt secrets OLD blob: %s\n", nt_errstr(status)); - return False; + return false; } if (!q.out.old_mtime) { printf("OLD mtime not available on LSA for secret %s\n", old->name); - ret = False; + ret = false; } if (old->mtime != *q.out.old_mtime) { printf("OLD mtime on secret %s does not match between SAMSYNC (%s) and LSA (%s)\n", old->name, nt_time_string(mem_ctx, old->mtime), nt_time_string(mem_ctx, *q.out.old_mtime)); - ret = False; + ret = false; } if (old->secret.length != lsa_blob_out.length) { printf("Returned secret %s doesn't match: %d != %d\n", old->name, (int)old->secret.length, (int)lsa_blob_out.length); - ret = False; + ret = false; } else if (memcmp(lsa_blob_out.data, old->secret.data, old->secret.length) != 0) { printf("Returned secret %s doesn't match: \n", @@ -902,7 +903,7 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam dump_data(1, old->secret.data, old->secret.length); DEBUG(1, ("LSA Secret:\n")); dump_data(1, lsa_blob_out.data, lsa_blob_out.length); - ret = False; + ret = false; } } @@ -916,24 +917,24 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam status = sess_decrypt_blob(mem_ctx, &lsa_blob1, &session_key, &lsa_blob_out); if (!NT_STATUS_IS_OK(status)) { printf("Failed to decrypt secrets OLD blob\n"); - return False; + return false; } if (!q.out.new_mtime) { printf("NEW mtime not available on LSA for secret %s\n", new->name); - ret = False; + ret = false; } if (new->mtime != *q.out.new_mtime) { printf("NEW mtime on secret %s does not match between SAMSYNC (%s) and LSA (%s)\n", new->name, nt_time_string(mem_ctx, new->mtime), nt_time_string(mem_ctx, *q.out.new_mtime)); - ret = False; + ret = false; } if (new->secret.length != lsa_blob_out.length) { printf("Returned secret %s doesn't match: %d != %d\n", new->name, (int)new->secret.length, (int)lsa_blob_out.length); - ret = False; + ret = false; } else if (memcmp(lsa_blob_out.data, new->secret.data, new->secret.length) != 0) { printf("Returned secret %s doesn't match: \n", @@ -942,18 +943,18 @@ static BOOL samsync_handle_secret(TALLOC_CTX *mem_ctx, struct samsync_state *sam dump_data(1, new->secret.data, new->secret.length); DEBUG(1, ("LSA Secret:\n")); dump_data(1, lsa_blob_out.data, lsa_blob_out.length); - ret = False; + ret = false; } } return ret; } -static BOOL samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, +static bool samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, int database_id, struct netr_DELTA_ENUM *delta) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct netr_DELTA_TRUSTED_DOMAIN *trusted_domain = delta->delta_union.trusted_domain; struct dom_sid *dom_sid = delta->delta_id_union.sid; @@ -976,7 +977,7 @@ static BOOL samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st status = dcerpc_lsa_OpenTrustedDomain(samsync_state->p_lsa, mem_ctx, &t); if (!NT_STATUS_IS_OK(status)) { printf("OpenTrustedDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } for (i=0; i< ARRAY_SIZE(levels); i++) { @@ -990,7 +991,7 @@ static BOOL samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st } printf("QueryInfoTrustedDomain level %d failed - %s\n", levels[i], nt_errstr(status)); - return False; + return false; } info[levels[i]] = q.out.info; } @@ -1011,11 +1012,11 @@ static BOOL samsync_handle_trusted_domain(TALLOC_CTX *mem_ctx, struct samsync_st return ret; } -static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, +static bool samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *samsync_state, int database_id, struct netr_DELTA_ENUM *delta) { NTSTATUS status; - BOOL ret = True; + bool ret = true; struct netr_DELTA_ACCOUNT *account = delta->delta_union.account; struct dom_sid *dom_sid = delta->delta_id_union.sid; @@ -1026,7 +1027,7 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa int i, j; - BOOL *found_priv_in_lsa; + bool *found_priv_in_lsa; a.in.handle = samsync_state->lsa_handle; a.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -1036,31 +1037,31 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa status = dcerpc_lsa_OpenAccount(samsync_state->p_lsa, mem_ctx, &a); if (!NT_STATUS_IS_OK(status)) { printf("OpenTrustedDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } TEST_SEC_DESC_EQUAL(account->sdbuf, lsa, &acct_handle); - found_priv_in_lsa = talloc_zero_array(mem_ctx, BOOL, account->privilege_entries); + found_priv_in_lsa = talloc_zero_array(mem_ctx, bool, account->privilege_entries); e.in.handle = &acct_handle; status = dcerpc_lsa_EnumPrivsAccount(samsync_state->p_lsa, mem_ctx, &e); if (!NT_STATUS_IS_OK(status)) { printf("EnumPrivsAccount failed - %s\n", nt_errstr(status)); - return False; + return false; } if ((account->privilege_entries && !e.out.privs)) { printf("Account %s has privileges in SamSync, but not LSA\n", dom_sid_string(mem_ctx, dom_sid)); - return False; + return false; } if (!account->privilege_entries && e.out.privs && e.out.privs->count) { printf("Account %s has privileges in LSA, but not SamSync\n", dom_sid_string(mem_ctx, dom_sid)); - return False; + return false; } TEST_INT_EQUAL(account->privilege_entries, e.out.privs->count); @@ -1072,16 +1073,16 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa status = dcerpc_lsa_LookupPrivName(samsync_state->p_lsa, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("\nLookupPrivName failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!r.out.name) { printf("\nLookupPrivName failed to return a name\n"); - return False; + return false; } for (j=0;j<account->privilege_entries; j++) { if (strcmp(r.out.name->string, account->privilege_name[j].string) == 0) { - found_priv_in_lsa[j] = True; + found_priv_in_lsa[j] = true; break; } } @@ -1090,7 +1091,7 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa if (!found_priv_in_lsa[j]) { printf("Privilage %s on account %s not found in LSA\n", account->privilege_name[j].string, dom_sid_string(mem_ctx, dom_sid)); - ret = False; + ret = false; } } return ret; @@ -1099,7 +1100,7 @@ static BOOL samsync_handle_account(TALLOC_CTX *mem_ctx, struct samsync_state *sa /* try a netlogon DatabaseSync */ -static BOOL test_DatabaseSync(struct samsync_state *samsync_state, +static bool test_DatabaseSync(struct samsync_state *samsync_state, TALLOC_CTX *mem_ctx) { NTSTATUS status; @@ -1107,7 +1108,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state, struct netr_DatabaseSync r; const enum netr_SamDatabaseID database_ids[] = {SAM_DATABASE_DOMAIN, SAM_DATABASE_BUILTIN, SAM_DATABASE_PRIVS}; int i, d; - BOOL ret = True; + bool ret = true; struct samsync_trusted_domain *t; struct samsync_secret *s; @@ -1132,7 +1133,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state, if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { printf("DatabaseSync - %s\n", nt_errstr(status)); - ret = False; + ret = false; break; } @@ -1149,56 +1150,56 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state, if (!samsync_handle_domain(delta_ctx, samsync_state, r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) { printf("Failed to handle DELTA_DOMAIN\n"); - ret = False; + ret = false; } break; case NETR_DELTA_GROUP: if (!samsync_handle_group(delta_ctx, samsync_state, r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) { printf("Failed to handle DELTA_USER\n"); - ret = False; + ret = false; } break; case NETR_DELTA_USER: if (!samsync_handle_user(delta_ctx, samsync_state, r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) { printf("Failed to handle DELTA_USER\n"); - ret = False; + ret = false; } break; case NETR_DELTA_ALIAS: if (!samsync_handle_alias(delta_ctx, samsync_state, r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) { printf("Failed to handle DELTA_ALIAS\n"); - ret = False; + ret = false; } break; case NETR_DELTA_POLICY: if (!samsync_handle_policy(delta_ctx, samsync_state, r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) { printf("Failed to handle DELTA_POLICY\n"); - ret = False; + ret = false; } break; case NETR_DELTA_TRUSTED_DOMAIN: if (!samsync_handle_trusted_domain(delta_ctx, samsync_state, r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) { printf("Failed to handle DELTA_TRUSTED_DOMAIN\n"); - ret = False; + ret = false; } break; case NETR_DELTA_ACCOUNT: if (!samsync_handle_account(delta_ctx, samsync_state, r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) { printf("Failed to handle DELTA_ACCOUNT\n"); - ret = False; + ret = false; } break; case NETR_DELTA_SECRET: if (!samsync_handle_secret(delta_ctx, samsync_state, r.in.database_id, &r.out.delta_enum_array->delta_enum[d])) { printf("Failed to handle DELTA_SECRET\n"); - ret = False; + ret = false; } break; case NETR_DELTA_GROUP_MEMBER: @@ -1219,7 +1220,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state, case NETR_DELTA_MODIFY_COUNT: default: printf("Uxpected delta type %d\n", r.out.delta_enum_array->delta_enum[d].delta_type); - ret = False; + ret = false; break; } talloc_free(delta_ctx); @@ -1232,7 +1233,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state, domain = samsync_state->domain_name[SAM_DATABASE_DOMAIN]; if (!domain) { printf("Never got a DOMAIN object in samsync!\n"); - return False; + return false; } trustdom_ctx = talloc_named(mem_ctx, 0, "test_DatabaseSync Trusted domains context"); @@ -1263,7 +1264,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state, if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT)) { printf("Verifiction of trust password to %s: should have failed (nologon interdomain trust account), instead: %s\n", t->name, nt_errstr(nt_status)); - ret = False; + ret = false; } /* break it */ @@ -1279,7 +1280,7 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state, if (!NT_STATUS_EQUAL(nt_status, NT_STATUS_WRONG_PASSWORD)) { printf("Verifiction of trust password to %s: should have failed (wrong password), instead: %s\n", t->name, nt_errstr(nt_status)); - ret = False; + ret = false; } break; @@ -1294,14 +1295,14 @@ static BOOL test_DatabaseSync(struct samsync_state *samsync_state, /* try a netlogon DatabaseDeltas */ -static BOOL test_DatabaseDeltas(struct samsync_state *samsync_state, TALLOC_CTX *mem_ctx) +static bool test_DatabaseDeltas(struct samsync_state *samsync_state, TALLOC_CTX *mem_ctx) { NTSTATUS status; TALLOC_CTX *loop_ctx; struct netr_DatabaseDeltas r; const uint32_t database_ids[] = {0, 1, 2}; int i; - BOOL ret = True; + bool ret = true; r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(samsync_state->p)); r.in.computername = TEST_MACHINE_NAME; @@ -1333,7 +1334,7 @@ static BOOL test_DatabaseDeltas(struct samsync_state *samsync_state, TALLOC_CTX !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES) && !NT_STATUS_EQUAL(status, NT_STATUS_SYNCHRONIZATION_REQUIRED)) { printf("DatabaseDeltas - %s\n", nt_errstr(status)); - ret = False; + ret = false; } if (!creds_client_check(samsync_state->creds, &r.out.return_authenticator.cred)) { @@ -1352,7 +1353,7 @@ static BOOL test_DatabaseDeltas(struct samsync_state *samsync_state, TALLOC_CTX /* try a netlogon DatabaseSync2 */ -static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct creds_CredentialState *creds) { NTSTATUS status; @@ -1360,7 +1361,7 @@ static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct netr_DatabaseSync2 r; const uint32_t database_ids[] = {0, 1, 2}; int i; - BOOL ret = True; + bool ret = true; r.in.logon_server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); r.in.computername = TEST_MACHINE_NAME; @@ -1382,7 +1383,7 @@ static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, STATUS_MORE_ENTRIES)) { printf("DatabaseSync2 - %s\n", nt_errstr(status)); - ret = False; + ret = false; } if (!creds_client_check(creds, &r.out.return_authenticator.cred)) { @@ -1399,11 +1400,11 @@ static BOOL test_DatabaseSync2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, -BOOL torture_rpc_samsync(struct torture_context *torture) +bool torture_rpc_samsync(struct torture_context *torture) { NTSTATUS status; TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct test_join *join_ctx; struct test_join *join_ctx2; struct test_join *user_ctx; @@ -1430,30 +1431,30 @@ BOOL torture_rpc_samsync(struct torture_context *torture) mem_ctx = talloc_init("torture_rpc_netlogon"); test_machine_account = talloc_asprintf(mem_ctx, "%s$", TEST_MACHINE_NAME); - join_ctx = torture_create_testuser(torture, test_machine_account, lp_workgroup(), ACB_SVRTRUST, + join_ctx = torture_create_testuser(torture, test_machine_account, + lp_workgroup(global_loadparm), ACB_SVRTRUST, &machine_password); if (!join_ctx) { talloc_free(mem_ctx); printf("Failed to join as BDC\n"); - return False; + return false; } test_wksta_machine_account = talloc_asprintf(mem_ctx, "%s$", TEST_WKSTA_MACHINE_NAME); - join_ctx2 = torture_create_testuser(torture, test_wksta_machine_account, lp_workgroup(), ACB_WSTRUST, - &wksta_machine_password); + join_ctx2 = torture_create_testuser(torture, test_wksta_machine_account, lp_workgroup(global_loadparm), ACB_WSTRUST, &wksta_machine_password); if (!join_ctx2) { talloc_free(mem_ctx); printf("Failed to join as member\n"); - return False; + return false; } user_ctx = torture_create_testuser(torture, TEST_USER_NAME, - lp_workgroup(), + lp_workgroup(global_loadparm), ACB_NORMAL, NULL); if (!user_ctx) { talloc_free(mem_ctx); printf("Failed to create test account\n"); - return False; + return false; } samsync_state = talloc_zero(mem_ctx, struct samsync_state); @@ -1468,14 +1469,14 @@ BOOL torture_rpc_samsync(struct torture_context *torture) status = dcerpc_samr_Connect(samsync_state->p_samr, mem_ctx, &c); if (!NT_STATUS_IS_OK(status)) { printf("samr_Connect failed\n"); - ret = False; + ret = false; goto failed; } - domain_policy = samsync_open_domain(mem_ctx, samsync_state, lp_workgroup(), NULL); + domain_policy = samsync_open_domain(mem_ctx, samsync_state, lp_workgroup(global_loadparm), NULL); if (!domain_policy) { printf("samrsync_open_domain failed\n"); - ret = False; + ret = false; goto failed; } @@ -1490,14 +1491,14 @@ BOOL torture_rpc_samsync(struct torture_context *torture) status = dcerpc_samr_SetDomainInfo(samsync_state->p_samr, mem_ctx, &s); if (!test_samr_handle_Close(samsync_state->p_samr, mem_ctx, domain_policy)) { - ret = False; + ret = false; goto failed; } if (!NT_STATUS_IS_OK(status)) { printf("SetDomainInfo level %u failed - %s\n", s.in.level, nt_errstr(status)); - ret = False; + ret = false; goto failed; } @@ -1507,7 +1508,7 @@ BOOL torture_rpc_samsync(struct torture_context *torture) &ndr_table_lsarpc); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto failed; } @@ -1531,13 +1532,13 @@ BOOL torture_rpc_samsync(struct torture_context *torture) status = dcerpc_lsa_OpenPolicy2(samsync_state->p_lsa, mem_ctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("OpenPolicy2 failed - %s\n", nt_errstr(status)); - ret = False; + ret = false; goto failed; } status = torture_rpc_binding(torture, &b); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto failed; } @@ -1547,7 +1548,7 @@ BOOL torture_rpc_samsync(struct torture_context *torture) credentials = cli_credentials_init(mem_ctx); cli_credentials_set_workstation(credentials, TEST_MACHINE_NAME, CRED_SPECIFIED); - cli_credentials_set_domain(credentials, lp_workgroup(), CRED_SPECIFIED); + cli_credentials_set_domain(credentials, lp_workgroup(global_loadparm), CRED_SPECIFIED); cli_credentials_set_username(credentials, test_machine_account, CRED_SPECIFIED); cli_credentials_set_password(credentials, machine_password, CRED_SPECIFIED); cli_credentials_set_secure_channel_type(credentials, @@ -1560,21 +1561,21 @@ BOOL torture_rpc_samsync(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to server as a BDC: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto failed; } status = dcerpc_schannel_creds(samsync_state->p->conn->security_state.generic_state, samsync_state, &samsync_state->creds); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; } status = torture_rpc_binding(torture, &b_netlogon_wksta); if (!NT_STATUS_IS_OK(status)) { - ret = False; + ret = false; goto failed; } @@ -1584,7 +1585,7 @@ BOOL torture_rpc_samsync(struct torture_context *torture) credentials_wksta = cli_credentials_init(mem_ctx); cli_credentials_set_workstation(credentials_wksta, TEST_WKSTA_MACHINE_NAME, CRED_SPECIFIED); - cli_credentials_set_domain(credentials_wksta, lp_workgroup(), CRED_SPECIFIED); + cli_credentials_set_domain(credentials_wksta, lp_workgroup(global_loadparm), CRED_SPECIFIED); cli_credentials_set_username(credentials_wksta, test_wksta_machine_account, CRED_SPECIFIED); cli_credentials_set_password(credentials_wksta, wksta_machine_password, CRED_SPECIFIED); cli_credentials_set_secure_channel_type(credentials_wksta, @@ -1598,7 +1599,7 @@ BOOL torture_rpc_samsync(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to server as a Workstation: %s\n", nt_errstr(status)); - ret = False; + ret = false; goto failed; } @@ -1606,22 +1607,22 @@ BOOL torture_rpc_samsync(struct torture_context *torture) samsync_state, &samsync_state->creds_netlogon_wksta); if (!NT_STATUS_IS_OK(status)) { printf("Failed to obtail schanel creds!\n"); - ret = False; + ret = false; } if (!test_DatabaseSync(samsync_state, mem_ctx)) { printf("DatabaseSync failed\n"); - ret = False; + ret = false; } if (!test_DatabaseDeltas(samsync_state, mem_ctx)) { printf("DatabaseDeltas failed\n"); - ret = False; + ret = false; } if (!test_DatabaseSync2(samsync_state->p, mem_ctx, samsync_state->creds)) { printf("DatabaseSync2 failed\n"); - ret = False; + ret = false; } failed: diff --git a/source4/torture/rpc/scanner.c b/source4/torture/rpc/scanner.c index b2dd99fd66..630e9cf1e4 100644 --- a/source4/torture/rpc/scanner.c +++ b/source4/torture/rpc/scanner.c @@ -24,11 +24,12 @@ #include "librpc/gen_ndr/ndr_mgmt_c.h" #include "librpc/ndr/ndr_table.h" #include "torture/rpc/rpc.h" +#include "param/param.h" /* work out how many calls there are for an interface */ -static BOOL test_num_calls(struct torture_context *tctx, +static bool test_num_calls(struct torture_context *tctx, const struct ndr_interface_table *iface, TALLOC_CTX *mem_ctx, struct ndr_syntax_id *id) @@ -51,7 +52,7 @@ static BOOL test_num_calls(struct torture_context *tctx, printf("Failed to connect to '%s' on '%s' - %s\n", uuid_str, iface->name, nt_errstr(status)); talloc_free(uuid_str); - return True; + return true; } /* make null calls */ @@ -59,7 +60,7 @@ static BOOL test_num_calls(struct torture_context *tctx, memset(stub_in.data, 0xFF, stub_in.length); for (i=0;i<200;i++) { - status = dcerpc_request(p, NULL, i, False, mem_ctx, &stub_in, &stub_out); + status = dcerpc_request(p, NULL, i, false, mem_ctx, &stub_in, &stub_out); if (!NT_STATUS_IS_OK(status) && p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) { break; @@ -88,30 +89,27 @@ static BOOL test_num_calls(struct torture_context *tctx, done: talloc_free(p); - return True; + return true; } -BOOL torture_rpc_scanner(struct torture_context *torture) +bool torture_rpc_scanner(struct torture_context *torture) { NTSTATUS status; struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx, *loop_ctx; - BOOL ret = True; + TALLOC_CTX *loop_ctx; + bool ret = true; const struct ndr_interface_list *l; struct dcerpc_binding *b; - mem_ctx = talloc_init("torture_rpc_scanner"); - status = torture_rpc_binding(torture, &b); if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; + return false; } for (l=ndr_table_list();l;l=l->next) { - loop_ctx = talloc_named(mem_ctx, 0, "torture_rpc_scanner loop context"); + loop_ctx = talloc_named(torture, 0, "torture_rpc_scanner loop context"); /* some interfaces are not mappable */ if (l->table->num_calls == 0 || strcmp(l->table->name, "mgmt") == 0) { @@ -122,7 +120,7 @@ BOOL torture_rpc_scanner(struct torture_context *torture) printf("\nTesting pipe '%s'\n", l->table->name); if (b->transport == NCACN_IP_TCP) { - status = dcerpc_epm_map_binding(mem_ctx, b, l->table, NULL); + status = dcerpc_epm_map_binding(torture, b, l->table, NULL); if (!NT_STATUS_IS_OK(status)) { printf("Failed to map port for uuid %s\n", GUID_string(loop_ctx, &l->table->syntax_id.uuid)); @@ -133,17 +131,17 @@ BOOL torture_rpc_scanner(struct torture_context *torture) b->endpoint = talloc_strdup(b, l->table->name); } - lp_set_cmdline("torture:binding", dcerpc_binding_string(mem_ctx, b)); + lp_set_cmdline(global_loadparm, "torture:binding", dcerpc_binding_string(torture, b)); status = torture_rpc_connection(torture, &p, &ndr_table_mgmt); if (!NT_STATUS_IS_OK(status)) { talloc_free(loop_ctx); - ret = False; + ret = false; continue; } - if (!test_inq_if_ids(torture, p, mem_ctx, test_num_calls, l->table)) { - ret = False; + if (!test_inq_if_ids(torture, p, torture, test_num_calls, l->table)) { + ret = false; } } diff --git a/source4/torture/rpc/schannel.c b/source4/torture/rpc/schannel.c index e072e592d1..a1a83c69d7 100644 --- a/source4/torture/rpc/schannel.c +++ b/source4/torture/rpc/schannel.c @@ -30,13 +30,14 @@ #include "libcli/auth/libcli_auth.h" #include "libcli/security/security.h" #include "system/filesys.h" +#include "param/param.h" #define TEST_MACHINE_NAME "schannel" /* try a netlogon SamLogon */ -BOOL test_netlogon_ex_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +bool test_netlogon_ex_ops(struct dcerpc_pipe *p, struct torture_context *tctx, struct cli_credentials *credentials, struct creds_CredentialState *creds) { @@ -45,17 +46,16 @@ BOOL test_netlogon_ex_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, struct netr_NetworkInfo ninfo; DATA_BLOB names_blob, chal, lm_resp, nt_resp; int i; - BOOL ret = True; int flags = CLI_CRED_NTLM_AUTH; - if (lp_client_lanman_auth()) { + if (lp_client_lanman_auth(global_loadparm)) { flags |= CLI_CRED_LANMAN_AUTH; } - if (lp_client_ntlmv2_auth()) { + if (lp_client_ntlmv2_auth(global_loadparm)) { flags |= CLI_CRED_NTLMv2_AUTH; } - cli_credentials_get_ntlm_username_domain(cmdline_credentials, mem_ctx, + cli_credentials_get_ntlm_username_domain(cmdline_credentials, tctx, &ninfo.identity_info.account_name.string, &ninfo.identity_info.domain_name.string); @@ -64,20 +64,17 @@ BOOL test_netlogon_ex_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, chal = data_blob_const(ninfo.challenge, sizeof(ninfo.challenge)); - names_blob = NTLMv2_generate_names_blob(mem_ctx, cli_credentials_get_workstation(credentials), + names_blob = NTLMv2_generate_names_blob(tctx, cli_credentials_get_workstation(credentials), cli_credentials_get_domain(credentials)); - status = cli_credentials_get_ntlm_response(cmdline_credentials, mem_ctx, + status = cli_credentials_get_ntlm_response(cmdline_credentials, tctx, &flags, chal, names_blob, &lm_resp, &nt_resp, NULL, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("cli_credentials_get_ntlm_response failed: %s\n", - nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, + "cli_credentials_get_ntlm_response failed"); ninfo.lm.data = lm_resp.data; ninfo.lm.length = lm_resp.length; @@ -90,32 +87,31 @@ BOOL test_netlogon_ex_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, ninfo.identity_info.logon_id_high = 0; ninfo.identity_info.workstation.string = cli_credentials_get_workstation(credentials); - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.computer_name = cli_credentials_get_workstation(credentials); r.in.logon_level = 2; r.in.logon.network = &ninfo; r.in.flags = 0; - printf("Testing LogonSamLogonEx with name %s\n", ninfo.identity_info.account_name.string); + torture_comment(tctx, + "Testing LogonSamLogonEx with name %s\n", + ninfo.identity_info.account_name.string); for (i=2;i<3;i++) { r.in.validation_level = i; - status = dcerpc_netr_LogonSamLogonEx(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("LogonSamLogon failed: %s\n", - nt_errstr(status)); - return False; - } + status = dcerpc_netr_LogonSamLogonEx(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "LogonSamLogon failed"); } - return ret; + return true; } /* do some samr ops using the schannel connection */ -static BOOL test_samr_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_samr_ops(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct samr_GetDomPwInfo r; @@ -126,7 +122,7 @@ static BOOL test_samr_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) struct policy_handle handle; struct policy_handle domain_handle; - name.string = lp_workgroup(); + name.string = lp_workgroup(global_loadparm); r.in.domain_name = &name; connect.in.system_name = 0; @@ -135,25 +131,25 @@ static BOOL test_samr_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) printf("Testing Connect and OpenDomain on BUILTIN\n"); - status = dcerpc_samr_Connect(p, mem_ctx, &connect); + status = dcerpc_samr_Connect(p, tctx, &connect); if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { printf("Connect failed (expected, schannel mapped to anonymous): %s\n", nt_errstr(status)); } else { printf("Connect failed - %s\n", nt_errstr(status)); - return False; + return false; } } else { opendom.in.connect_handle = &handle; opendom.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - opendom.in.sid = dom_sid_parse_talloc(mem_ctx, "S-1-5-32"); + opendom.in.sid = dom_sid_parse_talloc(tctx, "S-1-5-32"); opendom.out.domain_handle = &domain_handle; - status = dcerpc_samr_OpenDomain(p, mem_ctx, &opendom); + status = dcerpc_samr_OpenDomain(p, tctx, &opendom); if (!NT_STATUS_IS_OK(status)) { printf("OpenDomain failed - %s\n", nt_errstr(status)); - return False; + return false; } } @@ -161,27 +157,27 @@ static BOOL test_samr_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) /* do several ops to test credential chaining */ for (i=0;i<5;i++) { - status = dcerpc_samr_GetDomPwInfo(p, mem_ctx, &r); + status = dcerpc_samr_GetDomPwInfo(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { printf("GetDomPwInfo op %d failed - %s\n", i, nt_errstr(status)); - return False; + return false; } } } - return True; + return true; } /* do some lsa ops using the schannel connection */ -static BOOL test_lsa_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_lsa_ops(struct torture_context *tctx, struct dcerpc_pipe *p) { struct lsa_GetUserName r; NTSTATUS status; - BOOL ret = True; + bool ret = true; struct lsa_StringPointer authority_name_p; printf("\nTesting GetUserName\n"); @@ -192,36 +188,36 @@ static BOOL test_lsa_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) authority_name_p.string = NULL; /* do several ops to test credential chaining and various operations */ - status = dcerpc_lsa_GetUserName(p, mem_ctx, &r); + status = dcerpc_lsa_GetUserName(p, tctx, &r); if (NT_STATUS_EQUAL(status, NT_STATUS_RPC_PROTSEQ_NOT_SUPPORTED)) { printf("not considering %s to be an error\n", nt_errstr(status)); } else if (!NT_STATUS_IS_OK(status)) { printf("GetUserName failed - %s\n", nt_errstr(status)); - return False; + return false; } else { if (!r.out.account_name) { - return False; + return false; } if (strcmp(r.out.account_name->string, "ANONYMOUS LOGON") != 0) { printf("GetUserName returned wrong user: %s, expected %s\n", r.out.account_name->string, "ANONYMOUS LOGON"); - return False; + return false; } if (!r.out.authority_name || !r.out.authority_name->string) { - return False; + return false; } if (strcmp(r.out.authority_name->string->string, "NT AUTHORITY") != 0) { printf("GetUserName returned wrong user: %s, expected %s\n", r.out.authority_name->string->string, "NT AUTHORITY"); - return False; + return false; } } - if (!test_many_LookupSids(p, mem_ctx, NULL)) { + if (!test_many_LookupSids(p, tctx, NULL)) { printf("LsaLookupSids3 failed!\n"); - return False; + return false; } return ret; @@ -231,15 +227,13 @@ static BOOL test_lsa_ops(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) /* test a schannel connection with the given flags */ -static BOOL test_schannel(TALLOC_CTX *mem_ctx, +static bool test_schannel(struct torture_context *tctx, uint16_t acct_flags, uint32_t dcerpc_flags, int i) { - BOOL ret = True; - struct test_join *join_ctx; NTSTATUS status; - const char *binding = lp_parm_string(-1, "torture", "binding"); + const char *binding = lp_parm_string(global_loadparm, NULL, "torture", "binding"); struct dcerpc_binding *b; struct dcerpc_pipe *p = NULL; struct dcerpc_pipe *p_netlogon = NULL; @@ -250,105 +244,71 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx, struct creds_CredentialState *creds; struct cli_credentials *credentials; - TALLOC_CTX *test_ctx = talloc_named(mem_ctx, 0, "test_schannel context"); - - join_ctx = torture_join_domain(talloc_asprintf(mem_ctx, "%s%d", TEST_MACHINE_NAME, i), + join_ctx = torture_join_domain(talloc_asprintf(tctx, "%s%d", TEST_MACHINE_NAME, i), acct_flags, &credentials); - if (!join_ctx) { - printf("Failed to join domain with acct_flags=0x%x\n", acct_flags); - talloc_free(test_ctx); - return False; - } + torture_assert(tctx, join_ctx != NULL, "Failed to join domain"); - status = dcerpc_parse_binding(test_ctx, binding, &b); - if (!NT_STATUS_IS_OK(status)) { - printf("Bad binding string %s\n", binding); - goto failed; - } + status = dcerpc_parse_binding(tctx, binding, &b); + torture_assert_ntstatus_ok(tctx, status, "Bad binding string"); b->flags &= ~DCERPC_AUTH_OPTIONS; b->flags |= dcerpc_flags; - status = dcerpc_pipe_connect_b(test_ctx, &p, b, &ndr_table_samr, + status = dcerpc_pipe_connect_b(tctx, &p, b, &ndr_table_samr, credentials, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to connect with schannel: %s\n", nt_errstr(status)); - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, + "Failed to connect with schannel"); - if (!test_samr_ops(p, test_ctx)) { - printf("Failed to process schannel secured SAMR ops\n"); - ret = False; - } + torture_assert(tctx, test_samr_ops(tctx, p), + "Failed to process schannel secured SAMR ops"); /* Also test that when we connect to the netlogon pipe, that * the credentials we setup on the first pipe are valid for * the second */ /* Swap the binding details from SAMR to NETLOGON */ - status = dcerpc_epm_map_binding(test_ctx, b, &ndr_table_netlogon, NULL); - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL); + torture_assert_ntstatus_ok(tctx, status, "epm map"); status = dcerpc_secondary_connection(p, &p_netlogon, b); - - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, "seconday connection"); status = dcerpc_bind_auth(p_netlogon, &ndr_table_netlogon, credentials, DCERPC_AUTH_TYPE_SCHANNEL, dcerpc_auth_level(p->conn), NULL); - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, "bind auth"); - status = dcerpc_schannel_creds(p_netlogon->conn->security_state.generic_state, test_ctx, &creds); - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + status = dcerpc_schannel_creds(p_netlogon->conn->security_state.generic_state, tctx, &creds); + torture_assert_ntstatus_ok(tctx, status, "schannel creds"); /* do a couple of logins */ - if (!test_netlogon_ops(p_netlogon, test_ctx, credentials, creds)) { - printf("Failed to process schannel secured NETLOGON ops\n"); - ret = False; - } + torture_assert(tctx, test_netlogon_ops(p_netlogon, tctx, credentials, creds), + "Failed to process schannel secured NETLOGON ops"); - if (!test_netlogon_ex_ops(p_netlogon, test_ctx, credentials, creds)) { - printf("Failed to process schannel secured NETLOGON EX ops\n"); - ret = False; - } + torture_assert(tctx, test_netlogon_ex_ops(p_netlogon, tctx, credentials, creds), + "Failed to process schannel secured NETLOGON EX ops"); /* Swap the binding details from SAMR to LSARPC */ - status = dcerpc_epm_map_binding(test_ctx, b, &ndr_table_lsarpc, NULL); - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + status = dcerpc_epm_map_binding(tctx, b, &ndr_table_lsarpc, NULL); + torture_assert_ntstatus_ok(tctx, status, "epm map"); status = dcerpc_secondary_connection(p, &p_lsa, b); - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, "seconday connection"); status = dcerpc_bind_auth(p_lsa, &ndr_table_lsarpc, credentials, DCERPC_AUTH_TYPE_SCHANNEL, dcerpc_auth_level(p->conn), NULL); - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, "bind auth"); - if (!test_lsa_ops(p_lsa, test_ctx)) { - printf("Failed to process schannel secured LSA ops\n"); - ret = False; - } + torture_assert(tctx, test_lsa_ops(tctx, p_lsa), + "Failed to process schannel secured LSA ops"); /* Drop the socket, we want to start from scratch */ talloc_free(p); @@ -356,39 +316,28 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx, /* Now see what we are still allowed to do */ - status = dcerpc_parse_binding(test_ctx, binding, &b); - if (!NT_STATUS_IS_OK(status)) { - printf("Bad binding string %s\n", binding); - goto failed; - } + status = dcerpc_parse_binding(tctx, binding, &b); + torture_assert_ntstatus_ok(tctx, status, "Bad binding string"); b->flags &= ~DCERPC_AUTH_OPTIONS; b->flags |= dcerpc_flags; - status = dcerpc_pipe_connect_b(test_ctx, &p_samr2, b, &ndr_table_samr, + status = dcerpc_pipe_connect_b(tctx, &p_samr2, b, &ndr_table_samr, credentials, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to connect with schannel: %s\n", nt_errstr(status)); - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, + "Failed to connect with schannel"); /* do a some SAMR operations. We have *not* done a new serverauthenticate */ - if (!test_samr_ops(p_samr2, test_ctx)) { - printf("Failed to process schannel secured SAMR ops (on fresh connection)\n"); - goto failed; - } + torture_assert (tctx, test_samr_ops(tctx, p_samr2), + "Failed to process schannel secured SAMR ops (on fresh connection)"); /* Swap the binding details from SAMR to NETLOGON */ - status = dcerpc_epm_map_binding(test_ctx, b, &ndr_table_netlogon, NULL); - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + status = dcerpc_epm_map_binding(tctx, b, &ndr_table_netlogon, NULL); + torture_assert_ntstatus_ok(tctx, status, "epm"); status = dcerpc_secondary_connection(p_samr2, &p_netlogon2, b); - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, "seconday connection"); /* and now setup an SCHANNEL bind on netlogon */ status = dcerpc_bind_auth(p_netlogon2, &ndr_table_netlogon, @@ -396,22 +345,17 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx, dcerpc_auth_level(p_samr2->conn), NULL); - if (!NT_STATUS_IS_OK(status)) { - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, "auth failed"); /* Try the schannel-only SamLogonEx operation */ - if (!test_netlogon_ex_ops(p_netlogon2, test_ctx, credentials, creds)) { - printf("Failed to process schannel secured NETLOGON EX ops (on fresh connection)\n"); - ret = False; - } + torture_assert(tctx, test_netlogon_ex_ops(p_netlogon2, tctx, credentials, creds), + "Failed to process schannel secured NETLOGON EX ops (on fresh connection)"); + /* And the more traditional style, proving that the * credentials chaining state is fully present */ - if (!test_netlogon_ops(p_netlogon2, test_ctx, credentials, creds)) { - printf("Failed to process schannel secured NETLOGON ops (on fresh connection)\n"); - ret = False; - } + torture_assert(tctx, test_netlogon_ops(p_netlogon2, tctx, credentials, creds), + "Failed to process schannel secured NETLOGON ops (on fresh connection)"); /* Drop the socket, we want to start from scratch (again) */ talloc_free(p_samr2); @@ -419,31 +363,22 @@ static BOOL test_schannel(TALLOC_CTX *mem_ctx, /* We don't want schannel for this test */ b->flags &= ~DCERPC_AUTH_OPTIONS; - status = dcerpc_pipe_connect_b(test_ctx, &p_netlogon3, b, &ndr_table_netlogon, + status = dcerpc_pipe_connect_b(tctx, &p_netlogon3, b, &ndr_table_netlogon, credentials, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to connect without schannel: %s\n", nt_errstr(status)); - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, "Failed to connect without schannel"); - if (test_netlogon_ex_ops(p_netlogon3, test_ctx, credentials, creds)) { - printf("Processed NOT schannel secured NETLOGON EX ops without SCHANNEL (unsafe)\n"); - ret = False; - } + torture_assert(tctx, !test_netlogon_ex_ops(p_netlogon3, tctx, credentials, creds), + "Processed NOT schannel secured NETLOGON EX ops without SCHANNEL (unsafe)"); - if (!test_netlogon_ops(p_netlogon3, test_ctx, credentials, creds)) { - printf("Failed to processed NOT schannel secured NETLOGON ops without new ServerAuth\n"); - ret = False; - } + /* Required because the previous call will mark the current context as having failed */ + tctx->last_result = TORTURE_OK; + tctx->last_reason = NULL; - torture_leave_domain(join_ctx); - talloc_free(test_ctx); - return ret; + torture_assert(tctx, test_netlogon_ops(p_netlogon3, tctx, credentials, creds), + "Failed to processed NOT schannel secured NETLOGON ops without new ServerAuth"); -failed: torture_leave_domain(join_ctx); - talloc_free(test_ctx); - return False; + return true; } @@ -451,10 +386,9 @@ failed: /* a schannel test suite */ -BOOL torture_rpc_schannel(struct torture_context *torture) +bool torture_rpc_schannel(struct torture_context *torture) { - TALLOC_CTX *mem_ctx; - BOOL ret = True; + bool ret = true; struct { uint16_t acct_flags; uint32_t dcerpc_flags; @@ -470,112 +404,77 @@ BOOL torture_rpc_schannel(struct torture_context *torture) }; int i; - mem_ctx = talloc_init("torture_rpc_schannel"); - for (i=0;i<ARRAY_SIZE(tests);i++) { - if (!test_schannel(mem_ctx, + if (!test_schannel(torture, tests[i].acct_flags, tests[i].dcerpc_flags, i)) { - printf("Failed with acct_flags=0x%x dcerpc_flags=0x%x \n", + torture_comment(torture, "Failed with acct_flags=0x%x dcerpc_flags=0x%x \n", tests[i].acct_flags, tests[i].dcerpc_flags); - ret = False; - break; + ret = false; } } - talloc_free(mem_ctx); - return ret; } /* test two schannel connections */ -BOOL torture_rpc_schannel2(struct torture_context *torture) +bool torture_rpc_schannel2(struct torture_context *torture) { - BOOL ret = True; - TALLOC_CTX *mem_ctx = talloc_new(torture); struct test_join *join_ctx; NTSTATUS status; const char *binding = torture_setting_string(torture, "binding", NULL); struct dcerpc_binding *b; struct dcerpc_pipe *p1 = NULL, *p2 = NULL; struct cli_credentials *credentials1, *credentials2; - uint16_t acct_flags = ACB_WSTRUST; uint32_t dcerpc_flags = DCERPC_SCHANNEL | DCERPC_SIGN; - TALLOC_CTX *test_ctx = talloc_named(mem_ctx, 0, "test_schannel2 context"); - - join_ctx = torture_join_domain(talloc_asprintf(mem_ctx, "%s2", TEST_MACHINE_NAME), - acct_flags, &credentials1); - if (!join_ctx) { - printf("Failed to join domain with acct_flags=0x%x\n", acct_flags); - talloc_free(test_ctx); - return False; - } - credentials2 = talloc_memdup(mem_ctx, credentials1, sizeof(*credentials1)); + join_ctx = torture_join_domain(talloc_asprintf(torture, "%s2", TEST_MACHINE_NAME), + ACB_WSTRUST, &credentials1); + torture_assert(torture, join_ctx != NULL, + "Failed to join domain with acct_flags=ACB_WSTRUST"); + + credentials2 = (struct cli_credentials *)talloc_memdup(torture, credentials1, sizeof(*credentials1)); credentials1->netlogon_creds = NULL; credentials2->netlogon_creds = NULL; - status = dcerpc_parse_binding(test_ctx, binding, &b); - if (!NT_STATUS_IS_OK(status)) { - printf("Bad binding string %s\n", binding); - goto failed; - } + status = dcerpc_parse_binding(torture, binding, &b); + torture_assert_ntstatus_ok(torture, status, "Bad binding string"); b->flags &= ~DCERPC_AUTH_OPTIONS; b->flags |= dcerpc_flags; printf("Opening first connection\n"); - status = dcerpc_pipe_connect_b(test_ctx, &p1, b, &ndr_table_netlogon, + status = dcerpc_pipe_connect_b(torture, &p1, b, &ndr_table_netlogon, credentials1, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to connect with schannel: %s\n", nt_errstr(status)); - goto failed; - } + torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel"); - printf("Opening second connection\n"); - status = dcerpc_pipe_connect_b(test_ctx, &p2, b, &ndr_table_netlogon, + torture_comment(torture, "Opening second connection\n"); + status = dcerpc_pipe_connect_b(torture, &p2, b, &ndr_table_netlogon, credentials2, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to connect with schannel: %s\n", nt_errstr(status)); - goto failed; - } + torture_assert_ntstatus_ok(torture, status, "Failed to connect with schannel"); credentials1->netlogon_creds = NULL; credentials2->netlogon_creds = NULL; - printf("Testing logon on pipe1\n"); - if (!test_netlogon_ex_ops(p1, test_ctx, credentials1, NULL)) { - printf("Failed to process schannel secured NETLOGON ops\n"); - ret = False; - } - - printf("Testing logon on pipe2\n"); - if (!test_netlogon_ex_ops(p2, test_ctx, credentials2, NULL)) { - printf("Failed to process schannel secured NETLOGON ops\n"); - ret = False; - } + torture_comment(torture, "Testing logon on pipe1\n"); + if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL)) + return false; - printf("Again on pipe1\n"); - if (!test_netlogon_ex_ops(p1, test_ctx, credentials1, NULL)) { - printf("Failed to process schannel secured NETLOGON ops\n"); - ret = False; - } + torture_comment(torture, "Testing logon on pipe2\n"); + if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL)) + return false; - printf("Again on pipe2\n"); - if (!test_netlogon_ex_ops(p2, test_ctx, credentials2, NULL)) { - printf("Failed to process schannel secured NETLOGON ops\n"); - ret = False; - } + torture_comment(torture, "Again on pipe1\n"); + if (!test_netlogon_ex_ops(p1, torture, credentials1, NULL)) + return false; - torture_leave_domain(join_ctx); - talloc_free(test_ctx); - return ret; + torture_comment(torture, "Again on pipe2\n"); + if (!test_netlogon_ex_ops(p2, torture, credentials2, NULL)) + return false; -failed: torture_leave_domain(join_ctx); - talloc_free(test_ctx); - return False; + return true; } diff --git a/source4/torture/rpc/session_key.c b/source4/torture/rpc/session_key.c index c4b31be8a7..69dc8da6c1 100644 --- a/source4/torture/rpc/session_key.c +++ b/source4/torture/rpc/session_key.c @@ -25,14 +25,16 @@ #include "libcli/auth/libcli_auth.h" #include "torture/rpc/rpc.h" +#include "lib/cmdline/popt_common.h" +#include "param/param.h" static void init_lsa_String(struct lsa_String *name, const char *s) { name->string = s; } -static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p, - TALLOC_CTX *mem_ctx, +static bool test_CreateSecret_basic(struct dcerpc_pipe *p, + struct torture_context *tctx, struct policy_handle *handle) { NTSTATUS status; @@ -44,7 +46,6 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p, struct lsa_DATA_BUF buf1; struct lsa_DATA_BUF_PTR bufp1; DATA_BLOB enc_key; - BOOL ret = True; DATA_BLOB session_key; NTTIME old_mtime, new_mtime; DATA_BLOB blob1, blob2; @@ -52,9 +53,9 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p, char *secret2; char *secname; - secname = talloc_asprintf(mem_ctx, "torturesecret-%u", (uint_t)random()); + secname = talloc_asprintf(tctx, "torturesecret-%u", (uint_t)random()); - printf("Testing CreateSecret of %s\n", secname); + torture_comment(tctx, "Testing CreateSecret of %s\n", secname); init_lsa_String(&r.in.name, secname); @@ -62,17 +63,11 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p, r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r.out.sec_handle = &sec_handle; - status = dcerpc_lsa_CreateSecret(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("CreateSecret failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_lsa_CreateSecret(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "CreateSecret failed"); status = dcerpc_fetch_session_key(p, &session_key); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_fetch_session_key failed - %s\n", nt_errstr(status)); - ret = False; - } + torture_assert_ntstatus_ok(tctx, status, "dcerpc_fetch_session_key failed"); enc_key = sess_encrypt_string(secret1, &session_key); @@ -83,13 +78,10 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p, r3.in.new_val->length = enc_key.length; r3.in.new_val->size = enc_key.length; - printf("Testing SetSecret\n"); + torture_comment(tctx, "Testing SetSecret\n"); - status = dcerpc_lsa_SetSecret(p, mem_ctx, &r3); - if (!NT_STATUS_IS_OK(status)) { - printf("SetSecret failed - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_lsa_SetSecret(p, tctx, &r3); + torture_assert_ntstatus_ok(tctx, status, "SetSecret failed"); r3.in.sec_handle = &sec_handle; r3.in.new_val = &buf1; @@ -101,13 +93,11 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p, /* break the encrypted data */ enc_key.data[0]++; - printf("Testing SetSecret with broken key\n"); + torture_comment(tctx, "Testing SetSecret with broken key\n"); - status = dcerpc_lsa_SetSecret(p, mem_ctx, &r3); - if (!NT_STATUS_EQUAL(status, NT_STATUS_UNKNOWN_REVISION)) { - printf("SetSecret should have failed UNKNOWN_REVISION - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_lsa_SetSecret(p, tctx, &r3); + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_UNKNOWN_REVISION, + "SetSecret should have failed UNKNOWN_REVISION"); data_blob_free(&enc_key); @@ -123,73 +113,115 @@ static BOOL test_CreateSecret_basic(struct dcerpc_pipe *p, bufp1.buf = NULL; - printf("Testing QuerySecret\n"); - status = dcerpc_lsa_QuerySecret(p, mem_ctx, &r4); - if (!NT_STATUS_IS_OK(status)) { - printf("QuerySecret failed - %s\n", nt_errstr(status)); - ret = False; - } else { - if (r4.out.new_val == NULL || r4.out.new_val->buf == NULL) { - printf("No secret buffer returned\n"); - ret = False; - } else { - blob1.data = r4.out.new_val->buf->data; - blob1.length = r4.out.new_val->buf->size; - - blob2 = data_blob_talloc(mem_ctx, NULL, blob1.length); - - secret2 = sess_decrypt_string(mem_ctx, &blob1, &session_key); - - if (strcmp(secret1, secret2) != 0) { - printf("Returned secret '%s' doesn't match '%s'\n", - secret2, secret1); - ret = False; - } - } - } + torture_comment(tctx, "Testing QuerySecret\n"); + status = dcerpc_lsa_QuerySecret(p, tctx, &r4); + torture_assert_ntstatus_ok(tctx, status, "QuerySecret failed"); + if (r4.out.new_val == NULL || r4.out.new_val->buf == NULL) + torture_fail(tctx, "No secret buffer returned"); + blob1.data = r4.out.new_val->buf->data; + blob1.length = r4.out.new_val->buf->size; + + blob2 = data_blob_talloc(tctx, NULL, blob1.length); + + secret2 = sess_decrypt_string(tctx, &blob1, &session_key); + + torture_assert_str_equal(tctx, secret1, secret2, "Returned secret invalid"); d.in.handle = &sec_handle; - status = dcerpc_lsa_Delete(p, mem_ctx, &d); - if (!NT_STATUS_IS_OK(status)) { - printf("delete should have returned OKINVALID_HANDLE - %s\n", nt_errstr(status)); - ret = False; - } - return ret; + status = dcerpc_lsa_Delete(p, tctx, &d); + torture_assert_ntstatus_ok(tctx, status, "delete should have returned OKINVALID_HANDLE"); + return true; } +struct secret_settings { + uint32_t bindoptions; + bool keyexchange; + bool ntlm2; + bool lm_key; +}; -/* TEST session key correctness by pushing and pulling secrets */ - -BOOL torture_rpc_lsa_secrets(struct torture_context *torture) +static bool test_secrets(struct torture_context *torture, const void *_data) { - NTSTATUS status; struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; struct policy_handle *handle; + struct dcerpc_binding *binding; + const struct secret_settings *settings = + (const struct secret_settings *)_data; + + lp_set_cmdline(global_loadparm, "ntlmssp client:keyexchange", settings->keyexchange?"True":"False"); + lp_set_cmdline(global_loadparm, "ntlmssp_client:ntlm2", settings->ntlm2?"True":"False"); + lp_set_cmdline(global_loadparm, "ntlmssp_client:lm_key", settings->lm_key?"True":"False"); - mem_ctx = talloc_init("torture_rpc_lsa_secrets"); + torture_assert_ntstatus_ok(torture, torture_rpc_binding(torture, &binding), + "Getting bindoptions"); - status = torture_rpc_connection(torture, - &p, - &ndr_table_lsarpc); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; + binding->flags |= settings->bindoptions; + + torture_assert_ntstatus_ok(torture, + dcerpc_pipe_connect_b(torture, &p, binding, &ndr_table_lsarpc, cmdline_credentials, NULL), + "connect"); + + if (!test_lsa_OpenPolicy2(p, torture, &handle)) { + return false; } - if (test_lsa_OpenPolicy2(p, mem_ctx, &handle)) { - if (!handle) { - printf("OpenPolicy2 failed. This test cannot run against this server\n"); - ret = False; - } else if (!test_CreateSecret_basic(p, mem_ctx, handle)) { - ret = False; - } - } else { - return False; + torture_assert(torture, handle, "OpenPolicy2 failed. This test cannot run against this server"); + + if (!test_CreateSecret_basic(p, torture, handle)) { + return false; } - talloc_free(mem_ctx); + return true; +} + +static struct torture_tcase *add_test(struct torture_suite *suite, uint32_t bindoptions, + bool keyexchange, bool ntlm2, bool lm_key) +{ + char *name = NULL; + struct secret_settings *settings; + + settings = talloc_zero(suite, struct secret_settings); + settings->bindoptions = bindoptions; + + if (bindoptions == DCERPC_PUSH_BIGENDIAN) + name = talloc_strdup(suite, "bigendian"); + else if (bindoptions == DCERPC_SEAL) + name = talloc_strdup(suite, "seal"); + else if (bindoptions == 0) + name = talloc_strdup(suite, "none"); + else + name = talloc_strdup(suite, "unknown"); + + name = talloc_asprintf_append_buffer(name, " keyexchange:%s", keyexchange?"yes":"no"); + settings->keyexchange = keyexchange; + + name = talloc_asprintf_append_buffer(name, " ntlm2:%s", ntlm2?"yes":"no"); + settings->ntlm2 = ntlm2; + + name = talloc_asprintf_append_buffer(name, " lm_key:%s", lm_key?"yes":"no"); + settings->lm_key = lm_key; + + return torture_suite_add_simple_tcase(suite, name, test_secrets, settings); +} + +static const bool bool_vals[] = { true, false }; + +/* TEST session key correctness by pushing and pulling secrets */ +struct torture_suite *torture_rpc_lsa_secrets(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, "SECRETS"); + int keyexchange, ntlm2, lm_key; + + for (keyexchange = 0; keyexchange < ARRAY_SIZE(bool_vals); keyexchange++) { + for (ntlm2 = 0; ntlm2 < ARRAY_SIZE(bool_vals); ntlm2++) { + for (lm_key = 0; lm_key < ARRAY_SIZE(bool_vals); lm_key++) { + add_test(suite, DCERPC_PUSH_BIGENDIAN, bool_vals[keyexchange], bool_vals[ntlm2], + bool_vals[lm_key]); + add_test(suite, DCERPC_SEAL, bool_vals[keyexchange], bool_vals[ntlm2], bool_vals[lm_key]); + add_test(suite, 0, bool_vals[keyexchange], bool_vals[ntlm2], bool_vals[lm_key]); + } + } + } - return ret; + return suite; } diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 0bf0ee87a1..9cc42241d2 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -4,6 +4,7 @@ Copyright (C) Tim Potter 2003 Copyright (C) Stefan Metzmacher 2005 + Copyright (C) Jelmer Vernooij 2007 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 @@ -25,8 +26,6 @@ #include "librpc/gen_ndr/ndr_spoolss_c.h" struct test_spoolss_context { - struct dcerpc_pipe *p; - /* print server handle */ struct policy_handle server_handle; @@ -51,109 +50,58 @@ struct test_spoolss_context { union spoolss_PrinterInfo *printers[6]; }; -#define COMPARE_STRING(c,r,e) do {\ - BOOL _ok = True;\ - if (c.e && !r.e) _ok = False;\ - if (!c.e && r.e) _ok = False;\ - if (c.e && r.e && strcmp_safe(c.e, r.e) != 0) _ok = False;\ - if (!_ok){\ - printf("%s: " #c "." #e " [%s] doesn't match " #r "." #e " [%s]\n",\ - __location__, c.e, r.e);\ - ret = False;\ - }\ -} while(0) +#define COMPARE_STRING(tctx, c,r,e) \ + torture_assert_str_equal(tctx, c.e, r.e, "invalid value") /* not every compiler supports __typeof__() */ #if (__GNUC__ >= 3) #define _CHECK_FIELD_SIZE(c,r,e,type) do {\ if (sizeof(__typeof__(c.e)) != sizeof(type)) { \ - printf(__location__ ":" #c "." #e "field is not " #type "\n"); \ - smb_panic(__location__ ":" #c "." #e "field is not " #type ); \ - ret = False; \ + torture_fail(tctx, #c "." #e "field is not " #type "\n"); \ }\ if (sizeof(__typeof__(r.e)) != sizeof(type)) { \ - printf(__location__ ":" #r "." #e "field is not " #type "\n"); \ - smb_panic(__location__ ":" #r "." #e "field is not " #type ); \ - ret = False; \ + torture_fail(tctx, #r "." #e "field is not " #type "\n"); \ }\ } while(0) #else #define _CHECK_FIELD_SIZE(c,r,e,type) do {} while(0) #endif -#if 0 /* unused */ -#define COMPARE_UINT16(c,r,e) do {\ - _CHECK_FIELD_SIZE(c,r,e,uint16_t); \ - if (c.e != r.e){\ - printf("%s: " #c "." #e " 0x%04X (%u) doesn't match " #r "." #e " 0x%04X (%u)\n",\ - __location__, c.e, c.e, r.e, r.e);\ - ret = False;\ - }\ +#define COMPARE_UINT32(tctx, c, r, e) do {\ + _CHECK_FIELD_SIZE(c, r, e, uint32_t); \ + torture_assert_int_equal(tctx, c.e, r.e, "invalid value"); \ } while(0) -#endif -#define COMPARE_UINT32(c,r,e) do {\ - _CHECK_FIELD_SIZE(c,r,e,uint32_t); \ - if (c.e != r.e){\ - printf("%s: " #c "." #e " 0x%08X (%u) doesn't match " #r "." #e " 0x%08X (%u)\n",\ - __location__, c.e, c.e, r.e, r.e);\ - ret = False;\ - }\ -} while(0) +#define COMPARE_STRING_ARRAY(tctx, c,r,e) -#if 0 /* unused */ -#define COMPARE_UINT64(c,r,e) do {\ - _CHECK_FIELD_SIZE(c,r,e,uint64_t); \ - if (c.e != r.e){\ - printf("%s: " #c "." #e " 0x%016llX (%llu) doesn't match " #r "." #e " 0x%016llX (%llu)\n",\ - __location__, c.e, c.e, r.e, r.e);\ - ret = False;\ - }\ -} while(0) -#endif - -/* TODO: ! */ -#if 0 /* unused */ -#define COMPARE_SEC_DESC(c,r,e) -#define COMPARE_SPOOLSS_TIME(c,r,e) -#endif -#define COMPARE_STRING_ARRAY(c,r,e) - -static BOOL test_OpenPrinter_server(struct test_spoolss_context *ctx) +static bool test_OpenPrinter_server(struct torture_context *tctx, struct dcerpc_pipe *p, struct test_spoolss_context *ctx) { NTSTATUS status; struct spoolss_OpenPrinter op; - BOOL ret = True; - op.in.printername = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(ctx->p)); + op.in.printername = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p)); op.in.datatype = NULL; op.in.devmode_ctr.devmode= NULL; op.in.access_mask = 0; op.out.handle = &ctx->server_handle; - printf("\nTesting OpenPrinter(%s)\n", op.in.printername); + torture_comment(tctx, "Testing OpenPrinter(%s)\n", op.in.printername); - status = dcerpc_spoolss_OpenPrinter(ctx->p, ctx, &op); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_OpenPrinter failed - %s\n", nt_errstr(status)); - ret = False; - } - if (!W_ERROR_IS_OK(op.out.result)) { - printf("OpenPrinter(%s) failed - %s\n", - op.in.printername, win_errstr(op.out.result)); - ret = False; - } + status = dcerpc_spoolss_OpenPrinter(p, ctx, &op); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_OpenPrinter failed"); + torture_assert_werr_ok(tctx, op.out.result, "dcerpc_spoolss_OpenPrinter failed"); - return ret; + return true; } -static BOOL test_EnumPorts(struct test_spoolss_context *ctx) +static bool test_EnumPorts(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct test_spoolss_context *ctx) { NTSTATUS status; struct spoolss_EnumPorts r; uint16_t levels[] = { 1, 2 }; int i, j; - BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -164,43 +112,26 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx) r.in.buffer = NULL; r.in.offered = 0; - printf("Testing EnumPorts level %u\n", r.in.level); + torture_comment(tctx, "Testing EnumPorts level %u\n", r.in.level); - status = dcerpc_spoolss_EnumPorts(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumPorts failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumPorts(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPorts failed"); if (W_ERROR_IS_OK(r.out.result)) { /* TODO: do some more checks here */ continue; } - if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - printf("EnumPorts unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, + "EnumPorts unexpected return code"); blob = data_blob_talloc(ctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumPorts(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumPorts failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumPorts(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPorts failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("EnumPorts failed - %s\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_ok(tctx, r.out.result, "EnumPorts failed"); ctx->port_count[level] = r.out.count; ctx->ports[level] = r.out.info; @@ -209,14 +140,10 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx) for (i=1;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; int old_level = levels[i-1]; - if (ctx->port_count[level] != ctx->port_count[old_level]) { - printf("EnumPorts level[%d] returns [%u] ports, but level[%d] returns [%u]\n", - level, ctx->port_count[level], old_level, ctx->port_count[old_level]); - ret = False; - } + torture_assert_int_equal(tctx, ctx->port_count[level], ctx->port_count[old_level], + "EnumPorts invalid value"); } /* if the array sizes are not the same we would maybe segfault in the following code */ - if (!ret) return ret; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -225,7 +152,7 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx) union spoolss_PortInfo *ref = &ctx->ports[2][j]; switch (level) { case 1: - COMPARE_STRING(cur->info1, ref->info2, port_name); + COMPARE_STRING(tctx, cur->info1, ref->info2, port_name); break; case 2: /* level 2 is our reference, and it makes no sense to compare it to itself */ @@ -234,10 +161,12 @@ static BOOL test_EnumPorts(struct test_spoolss_context *ctx) } } - return True; + return true; } -static BOOL test_GetPrinterDriverDirectory(struct test_spoolss_context *ctx) +static bool test_GetPrinterDriverDirectory(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct test_spoolss_context *ctx) { NTSTATUS status; struct spoolss_GetPrinterDriverDirectory r; @@ -255,14 +184,13 @@ static BOOL test_GetPrinterDriverDirectory(struct test_spoolss_context *ctx) .server = "" },{ .level = 1, - .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(ctx->p)) + .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p)) },{ .level = 1024, - .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(ctx->p)) + .server = talloc_asprintf(ctx, "\\\\%s", dcerpc_server_name(p)) } }; int i; - BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i].level; @@ -274,51 +202,36 @@ static BOOL test_GetPrinterDriverDirectory(struct test_spoolss_context *ctx) r.in.buffer = NULL; r.in.offered = 0; - printf("Testing GetPrinterDriverDirectory level %u\n", r.in.level); + torture_comment(tctx, "Testing GetPrinterDriverDirectory level %u\n", r.in.level); - status = dcerpc_spoolss_GetPrinterDriverDirectory(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_GetPrinterDriverDirectory failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } - if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - printf("GetPrinterDriverDirectory unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + status = dcerpc_spoolss_GetPrinterDriverDirectory(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_spoolss_GetPrinterDriverDirectory failed"); + torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, + "GetPrinterDriverDirectory unexpected return code"); blob = data_blob_talloc(ctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_GetPrinterDriverDirectory(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_GetPrinterDriverDirectory failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_GetPrinterDriverDirectory(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_GetPrinterDriverDirectory failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("GetPrinterDriverDirectory failed - %s\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_ok(tctx, r.out.result, "GetPrinterDriverDirectory failed"); } - return True; + return true; } -static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx) +static bool test_EnumPrinterDrivers(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct test_spoolss_context *ctx) { NTSTATUS status; struct spoolss_EnumPrinterDrivers r; uint16_t levels[] = { 1, 2, 3, 4, 5, 6 }; int i, j; - BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -330,43 +243,27 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx) r.in.buffer = NULL; r.in.offered = 0; - printf("Testing EnumPrinterDrivers level %u\n", r.in.level); + torture_comment(tctx, "Testing EnumPrinterDrivers level %u\n", r.in.level); - status = dcerpc_spoolss_EnumPrinterDrivers(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumPrinterDrivers failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumPrinterDrivers(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_spoolss_EnumPrinterDrivers failed"); if (W_ERROR_IS_OK(r.out.result)) { /* TODO: do some more checks here */ continue; } - if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - printf("EnumPrinterDrivers unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, + "EnumPrinterDrivers failed"); blob = data_blob_talloc(ctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumPrinterDrivers(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumPrinterDrivers failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumPrinterDrivers(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinterDrivers failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("EnumPrinterDrivers failed - %s\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_ok(tctx, r.out.result, "EnumPrinterDrivers failed"); ctx->driver_count[level] = r.out.count; ctx->drivers[level] = r.out.info; @@ -375,14 +272,9 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx) for (i=1;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; int old_level = levels[i-1]; - if (ctx->driver_count[level] != ctx->driver_count[old_level]) { - printf("EnumPrinterDrivers level[%d] returns [%u] drivers, but level[%d] returns [%u]\n", - level, ctx->driver_count[level], old_level, ctx->driver_count[old_level]); - ret = False; - } + torture_assert_int_equal(tctx, ctx->driver_count[level], ctx->driver_count[old_level], + "EnumPrinterDrivers invalid value"); } - /* if the array sizes are not the same we would maybe segfault in the following code */ - if (!ret) return ret; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -391,51 +283,51 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx) union spoolss_DriverInfo *ref = &ctx->drivers[6][j]; switch (level) { case 1: - COMPARE_STRING(cur->info1, ref->info6, driver_name); + COMPARE_STRING(tctx, cur->info1, ref->info6, driver_name); break; case 2: - COMPARE_UINT32(cur->info2, ref->info6, version); - COMPARE_STRING(cur->info2, ref->info6, driver_name); - COMPARE_STRING(cur->info2, ref->info6, architecture); - COMPARE_STRING(cur->info2, ref->info6, driver_path); - COMPARE_STRING(cur->info2, ref->info6, data_file); - COMPARE_STRING(cur->info2, ref->info6, config_file); + COMPARE_UINT32(tctx, cur->info2, ref->info6, version); + COMPARE_STRING(tctx, cur->info2, ref->info6, driver_name); + COMPARE_STRING(tctx, cur->info2, ref->info6, architecture); + COMPARE_STRING(tctx, cur->info2, ref->info6, driver_path); + COMPARE_STRING(tctx, cur->info2, ref->info6, data_file); + COMPARE_STRING(tctx, cur->info2, ref->info6, config_file); break; case 3: - COMPARE_UINT32(cur->info3, ref->info6, version); - COMPARE_STRING(cur->info3, ref->info6, driver_name); - COMPARE_STRING(cur->info3, ref->info6, architecture); - COMPARE_STRING(cur->info3, ref->info6, driver_path); - COMPARE_STRING(cur->info3, ref->info6, data_file); - COMPARE_STRING(cur->info3, ref->info6, config_file); - COMPARE_STRING(cur->info3, ref->info6, help_file); - COMPARE_STRING_ARRAY(cur->info3, ref->info6, dependent_files); - COMPARE_STRING(cur->info3, ref->info6, monitor_name); - COMPARE_STRING(cur->info3, ref->info6, default_datatype); + COMPARE_UINT32(tctx, cur->info3, ref->info6, version); + COMPARE_STRING(tctx, cur->info3, ref->info6, driver_name); + COMPARE_STRING(tctx, cur->info3, ref->info6, architecture); + COMPARE_STRING(tctx, cur->info3, ref->info6, driver_path); + COMPARE_STRING(tctx, cur->info3, ref->info6, data_file); + COMPARE_STRING(tctx, cur->info3, ref->info6, config_file); + COMPARE_STRING(tctx, cur->info3, ref->info6, help_file); + COMPARE_STRING_ARRAY(tctx, cur->info3, ref->info6, dependent_files); + COMPARE_STRING(tctx, cur->info3, ref->info6, monitor_name); + COMPARE_STRING(tctx, cur->info3, ref->info6, default_datatype); break; case 4: - COMPARE_UINT32(cur->info4, ref->info6, version); - COMPARE_STRING(cur->info4, ref->info6, driver_name); - COMPARE_STRING(cur->info4, ref->info6, architecture); - COMPARE_STRING(cur->info4, ref->info6, driver_path); - COMPARE_STRING(cur->info4, ref->info6, data_file); - COMPARE_STRING(cur->info4, ref->info6, config_file); - COMPARE_STRING(cur->info4, ref->info6, help_file); - COMPARE_STRING_ARRAY(cur->info4, ref->info6, dependent_files); - COMPARE_STRING(cur->info4, ref->info6, monitor_name); - COMPARE_STRING(cur->info4, ref->info6, default_datatype); - COMPARE_STRING_ARRAY(cur->info4, ref->info6, previous_names); + COMPARE_UINT32(tctx, cur->info4, ref->info6, version); + COMPARE_STRING(tctx, cur->info4, ref->info6, driver_name); + COMPARE_STRING(tctx, cur->info4, ref->info6, architecture); + COMPARE_STRING(tctx, cur->info4, ref->info6, driver_path); + COMPARE_STRING(tctx, cur->info4, ref->info6, data_file); + COMPARE_STRING(tctx, cur->info4, ref->info6, config_file); + COMPARE_STRING(tctx, cur->info4, ref->info6, help_file); + COMPARE_STRING_ARRAY(tctx, cur->info4, ref->info6, dependent_files); + COMPARE_STRING(tctx, cur->info4, ref->info6, monitor_name); + COMPARE_STRING(tctx, cur->info4, ref->info6, default_datatype); + COMPARE_STRING_ARRAY(tctx, cur->info4, ref->info6, previous_names); break; case 5: - COMPARE_UINT32(cur->info5, ref->info6, version); - COMPARE_STRING(cur->info5, ref->info6, driver_name); - COMPARE_STRING(cur->info5, ref->info6, architecture); - COMPARE_STRING(cur->info5, ref->info6, driver_path); - COMPARE_STRING(cur->info5, ref->info6, data_file); - COMPARE_STRING(cur->info5, ref->info6, config_file); - /*COMPARE_UINT32(cur->info5, ref->info6, driver_attributes);*/ - /*COMPARE_UINT32(cur->info5, ref->info6, config_version);*/ - /*TODO: ! COMPARE_UINT32(cur->info5, ref->info6, driver_version); */ + COMPARE_UINT32(tctx, cur->info5, ref->info6, version); + COMPARE_STRING(tctx, cur->info5, ref->info6, driver_name); + COMPARE_STRING(tctx, cur->info5, ref->info6, architecture); + COMPARE_STRING(tctx, cur->info5, ref->info6, driver_path); + COMPARE_STRING(tctx, cur->info5, ref->info6, data_file); + COMPARE_STRING(tctx, cur->info5, ref->info6, config_file); + /*COMPARE_UINT32(tctx, cur->info5, ref->info6, driver_attributes);*/ + /*COMPARE_UINT32(tctx, cur->info5, ref->info6, config_version);*/ + /*TODO: ! COMPARE_UINT32(tctx, cur->info5, ref->info6, driver_version); */ break; case 6: /* level 6 is our reference, and it makes no sense to compare it to itself */ @@ -444,16 +336,17 @@ static BOOL test_EnumPrinterDrivers(struct test_spoolss_context *ctx) } } - return ret; + return true; } -static BOOL test_EnumMonitors(struct test_spoolss_context *ctx) +static bool test_EnumMonitors(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct test_spoolss_context *ctx) { NTSTATUS status; struct spoolss_EnumMonitors r; uint16_t levels[] = { 1, 2 }; int i, j; - BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -464,43 +357,26 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx) r.in.buffer = NULL; r.in.offered = 0; - printf("Testing EnumMonitors level %u\n", r.in.level); + torture_comment(tctx, "Testing EnumMonitors level %u\n", r.in.level); - status = dcerpc_spoolss_EnumMonitors(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumMonitors failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumMonitors(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumMonitors failed"); if (W_ERROR_IS_OK(r.out.result)) { /* TODO: do some more checks here */ continue; } - if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - printf("EnumMonitors unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, + "EnumMonitors failed"); blob = data_blob_talloc(ctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumMonitors(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumMonitors failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumMonitors(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumMonitors failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("EnumMonitors failed - %s\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_ok(tctx, r.out.result, "EnumMonitors failed"); ctx->monitor_count[level] = r.out.count; ctx->monitors[level] = r.out.info; @@ -509,14 +385,9 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx) for (i=1;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; int old_level = levels[i-1]; - if (ctx->monitor_count[level] != ctx->monitor_count[old_level]) { - printf("EnumMonitors level[%d] returns [%u] monitors, but level[%d] returns [%u]\n", - level, ctx->monitor_count[level], old_level, ctx->monitor_count[old_level]); - ret = False; - } + torture_assert_int_equal(tctx, ctx->monitor_count[level], ctx->monitor_count[old_level], + "EnumMonitors invalid value"); } - /* if the array sizes are not the same we would maybe segfault in the following code */ - if (!ret) return ret; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -525,7 +396,7 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx) union spoolss_MonitorInfo *ref = &ctx->monitors[2][j]; switch (level) { case 1: - COMPARE_STRING(cur->info1, ref->info2, monitor_name); + COMPARE_STRING(tctx, cur->info1, ref->info2, monitor_name); break; case 2: /* level 2 is our reference, and it makes no sense to compare it to itself */ @@ -534,16 +405,17 @@ static BOOL test_EnumMonitors(struct test_spoolss_context *ctx) } } - return ret; + return true; } -static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx) +static bool test_EnumPrintProcessors(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct test_spoolss_context *ctx) { NTSTATUS status; struct spoolss_EnumPrintProcessors r; uint16_t levels[] = { 1 }; int i, j; - BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -555,43 +427,26 @@ static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx) r.in.buffer = NULL; r.in.offered = 0; - printf("Testing EnumPrintProcessors level %u\n", r.in.level); + torture_comment(tctx, "Testing EnumPrintProcessors level %u\n", r.in.level); - status = dcerpc_spoolss_EnumPrintProcessors(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumPrintProcessors failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumPrintProcessors(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrintProcessors failed"); if (W_ERROR_IS_OK(r.out.result)) { /* TODO: do some more checks here */ continue; } - if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - printf("EnumPrintProcessors unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, + "EnumPrintProcessors unexpected return code"); blob = data_blob_talloc(ctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumPrintProcessors(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumPrintProcessors failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumPrintProcessors(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrintProcessors failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("EnumPrintProcessors failed - %s\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_ok(tctx, r.out.result, "EnumPrintProcessors failed"); ctx->print_processor_count[level] = r.out.count; ctx->print_processors[level] = r.out.info; @@ -600,14 +455,9 @@ static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx) for (i=1;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; int old_level = levels[i-1]; - if (ctx->print_processor_count[level] != ctx->print_processor_count[old_level]) { - printf("EnumPrintProcessors level[%d] returns [%u] print_processors, but level[%d] returns [%u]\n", - level, ctx->print_processor_count[level], old_level, ctx->print_processor_count[old_level]); - ret = False; - } + torture_assert_int_equal(tctx, ctx->print_processor_count[level], ctx->print_processor_count[old_level], + "EnumPrintProcessors failed"); } - /* if the array sizes are not the same we would maybe segfault in the following code */ - if (!ret) return ret; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -624,16 +474,17 @@ static BOOL test_EnumPrintProcessors(struct test_spoolss_context *ctx) } } - return ret; + return true; } -static BOOL test_EnumPrinters(struct test_spoolss_context *ctx) +static bool test_EnumPrinters(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct test_spoolss_context *ctx) { struct spoolss_EnumPrinters r; NTSTATUS status; uint16_t levels[] = { 0, 1, 2, 4, 5 }; int i, j; - BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -645,42 +496,26 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx) r.in.buffer = NULL; r.in.offered = 0; - printf("\nTesting EnumPrinters level %u\n", r.in.level); + torture_comment(tctx, "Testing EnumPrinters level %u\n", r.in.level); - status = dcerpc_spoolss_EnumPrinters(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumPrinters failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumPrinters(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinters failed"); if (W_ERROR_IS_OK(r.out.result)) { /* TODO: do some more checks here */ continue; } - if (!W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - printf("EnumPrinters unexspected return code %s, should be WERR_INSUFFICIENT_BUFFER\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_equal(tctx, r.out.result, WERR_INSUFFICIENT_BUFFER, + "EnumPrinters unexpected return code"); blob = data_blob_talloc(ctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumPrinters(ctx->p, ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EnumPrinters failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumPrinters(p, ctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EnumPrinters failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("EnumPrinters failed - %s\n", - win_errstr(r.out.result)); - continue; - } + torture_assert_werr_ok(tctx, r.out.result, "EnumPrinters failed"); ctx->printer_count[level] = r.out.count; ctx->printers[level] = r.out.info; @@ -689,14 +524,9 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx) for (i=1;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; int old_level = levels[i-1]; - if (ctx->printer_count[level] != ctx->printer_count[old_level]) { - printf("EnumPrinters level[%d] returns [%u] printers, but level[%d] returns [%u]\n", - level, ctx->printer_count[level], old_level, ctx->printer_count[old_level]); - ret = False; - } + torture_assert_int_equal(tctx, ctx->printer_count[level], ctx->printer_count[old_level], + "EnumPrinters invalid value"); } - /* if the array sizes are not the same we would maybe segfault in the following code */ - if (!ret) return ret; for (i=0;i<ARRAY_SIZE(levels);i++) { int level = levels[i]; @@ -705,56 +535,56 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx) union spoolss_PrinterInfo *ref = &ctx->printers[2][j]; switch (level) { case 0: - COMPARE_STRING(cur->info0, ref->info2, printername); - COMPARE_STRING(cur->info0, ref->info2, servername); - COMPARE_UINT32(cur->info0, ref->info2, cjobs); - /*COMPARE_UINT32(cur->info0, ref->info2, total_jobs); - COMPARE_UINT32(cur->info0, ref->info2, total_bytes); + COMPARE_STRING(tctx, cur->info0, ref->info2, printername); + COMPARE_STRING(tctx, cur->info0, ref->info2, servername); + COMPARE_UINT32(tctx, cur->info0, ref->info2, cjobs); + /*COMPARE_UINT32(tctx, cur->info0, ref->info2, total_jobs); + COMPARE_UINT32(tctx, cur->info0, ref->info2, total_bytes); COMPARE_SPOOLSS_TIME(cur->info0, ref->info2, spoolss_Time time); - COMPARE_UINT32(cur->info0, ref->info2, global_counter); - COMPARE_UINT32(cur->info0, ref->info2, total_pages); - COMPARE_UINT32(cur->info0, ref->info2, version); - COMPARE_UINT32(cur->info0, ref->info2, unknown10); - COMPARE_UINT32(cur->info0, ref->info2, unknown11); - COMPARE_UINT32(cur->info0, ref->info2, unknown12); - COMPARE_UINT32(cur->info0, ref->info2, session_counter); - COMPARE_UINT32(cur->info0, ref->info2, unknown14); - COMPARE_UINT32(cur->info0, ref->info2, printer_errors); - COMPARE_UINT32(cur->info0, ref->info2, unknown16); - COMPARE_UINT32(cur->info0, ref->info2, unknown17); - COMPARE_UINT32(cur->info0, ref->info2, unknown18); - COMPARE_UINT32(cur->info0, ref->info2, unknown19); - COMPARE_UINT32(cur->info0, ref->info2, change_id); - COMPARE_UINT32(cur->info0, ref->info2, unknown21);*/ - COMPARE_UINT32(cur->info0, ref->info2, status); - /*COMPARE_UINT32(cur->info0, ref->info2, unknown23); - COMPARE_UINT32(cur->info0, ref->info2, c_setprinter); + COMPARE_UINT32(tctx, cur->info0, ref->info2, global_counter); + COMPARE_UINT32(tctx, cur->info0, ref->info2, total_pages); + COMPARE_UINT32(tctx, cur->info0, ref->info2, version); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown10); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown11); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown12); + COMPARE_UINT32(tctx, cur->info0, ref->info2, session_counter); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown14); + COMPARE_UINT32(tctx, cur->info0, ref->info2, printer_errors); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown16); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown17); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown18); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown19); + COMPARE_UINT32(tctx, cur->info0, ref->info2, change_id); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown21);*/ + COMPARE_UINT32(tctx, cur->info0, ref->info2, status); + /*COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown23); + COMPARE_UINT32(tctx, cur->info0, ref->info2, c_setprinter); COMPARE_UINT16(cur->info0, ref->info2, unknown25); COMPARE_UINT16(cur->info0, ref->info2, unknown26); - COMPARE_UINT32(cur->info0, ref->info2, unknown27); - COMPARE_UINT32(cur->info0, ref->info2, unknown28); - COMPARE_UINT32(cur->info0, ref->info2, unknown29);*/ + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown27); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown28); + COMPARE_UINT32(tctx, cur->info0, ref->info2, unknown29);*/ break; case 1: - /*COMPARE_UINT32(cur->info1, ref->info2, flags);*/ - /*COMPARE_STRING(cur->info1, ref->info2, name);*/ - /*COMPARE_STRING(cur->info1, ref->info2, description);*/ - COMPARE_STRING(cur->info1, ref->info2, comment); + /*COMPARE_UINT32(tctx, cur->info1, ref->info2, flags);*/ + /*COMPARE_STRING(tctx, cur->info1, ref->info2, name);*/ + /*COMPARE_STRING(tctx, cur->info1, ref->info2, description);*/ + COMPARE_STRING(tctx, cur->info1, ref->info2, comment); break; case 2: /* level 2 is our reference, and it makes no sense to compare it to itself */ break; case 4: - COMPARE_STRING(cur->info4, ref->info2, printername); - COMPARE_STRING(cur->info4, ref->info2, servername); - COMPARE_UINT32(cur->info4, ref->info2, attributes); + COMPARE_STRING(tctx, cur->info4, ref->info2, printername); + COMPARE_STRING(tctx, cur->info4, ref->info2, servername); + COMPARE_UINT32(tctx, cur->info4, ref->info2, attributes); break; case 5: - COMPARE_STRING(cur->info5, ref->info2, printername); - COMPARE_STRING(cur->info5, ref->info2, portname); - COMPARE_UINT32(cur->info5, ref->info2, attributes); - /*COMPARE_UINT32(cur->info5, ref->info2, device_not_selected_timeout); - COMPARE_UINT32(cur->info5, ref->info2, transmission_retry_timeout);*/ + COMPARE_STRING(tctx, cur->info5, ref->info2, printername); + COMPARE_STRING(tctx, cur->info5, ref->info2, portname); + COMPARE_UINT32(tctx, cur->info5, ref->info2, attributes); + /*COMPARE_UINT32(tctx, cur->info5, ref->info2, device_not_selected_timeout); + COMPARE_UINT32(tctx, cur->info5, ref->info2, transmission_retry_timeout);*/ break; } } @@ -764,17 +594,17 @@ static BOOL test_EnumPrinters(struct test_spoolss_context *ctx) * - verify that the port of a printer was in the list returned by EnumPorts */ - return ret; + return true; } -static BOOL test_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetPrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, struct policy_handle *handle) { NTSTATUS status; struct spoolss_GetPrinter r; uint16_t levels[] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; int i; - BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { r.in.handle = handle; @@ -782,43 +612,31 @@ static BOOL test_GetPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.buffer = NULL; r.in.offered = 0; - printf("Testing GetPrinter level %u\n", r.in.level); + torture_comment(tctx, "Testing GetPrinter level %u\n", r.in.level); - status = dcerpc_spoolss_GetPrinter(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetPrinter failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_GetPrinter(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_GetPrinter(p, mem_ctx, &r); + status = dcerpc_spoolss_GetPrinter(p, tctx, &r); } - if (!NT_STATUS_IS_OK(status)) { - printf("GetPrinter failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "GetPrinter failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("GetPrinter failed - %s\n", - win_errstr(r.out.result)); - ret = False; - continue; - } + torture_assert_werr_ok(tctx, r.out.result, "GetPrinter failed"); } - return ret; + return true; } -static BOOL test_ClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_ClosePrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) { NTSTATUS status; struct spoolss_ClosePrinter r; @@ -826,18 +644,16 @@ static BOOL test_ClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.handle = handle; r.out.handle = handle; - printf("Testing ClosePrinter\n"); + torture_comment(tctx, "Testing ClosePrinter\n"); - status = dcerpc_spoolss_ClosePrinter(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ClosePrinter failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_ClosePrinter(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed"); - return True; + return true; } -static BOOL test_GetForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetForm(struct torture_context *tctx, + struct dcerpc_pipe *p, struct policy_handle *handle, const char *form_name) { @@ -850,109 +666,79 @@ static BOOL test_GetForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.buffer = NULL; r.in.offered = 0; - printf("Testing GetForm\n"); + torture_comment(tctx, "Testing GetForm\n"); - status = dcerpc_spoolss_GetForm(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetForm failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_GetForm(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetForm failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_GetForm(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetForm failed - %s\n", - nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_GetForm(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetForm failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("GetForm failed - %s\n", - win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "GetForm failed"); - if (!r.out.info) { - printf("No form info returned\n"); - return False; - } + torture_assert(tctx, r.out.info, "No form info returned"); } + torture_assert_werr_ok(tctx, r.out.result, "GetForm failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("GetForm failed - %s\n", - win_errstr(r.out.result)); - return False; - } - - return True; + return true; } -static BOOL test_EnumForms(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, BOOL print_server) +static bool test_EnumForms(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle, bool print_server) { NTSTATUS status; struct spoolss_EnumForms r; - BOOL ret = True; + bool ret = true; r.in.handle = handle; r.in.level = 1; r.in.buffer = NULL; r.in.offered = 0; - printf("Testing EnumForms\n"); + torture_comment(tctx, "Testing EnumForms\n"); - status = dcerpc_spoolss_EnumForms(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumForms failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_EnumForms(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "EnumForms failed"); - if (print_server && W_ERROR_EQUAL(r.out.result,WERR_BADFID)) { - printf("EnumForms on the PrintServer isn't supported by test server (NT4)\n"); - return True; - } + if (print_server && W_ERROR_EQUAL(r.out.result, WERR_BADFID)) + torture_fail(tctx, "EnumForms on the PrintServer isn't supported by test server (NT4)"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { union spoolss_FormInfo *info; int j; - DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumForms(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumForms(p, tctx, &r); - if (!r.out.info) { - printf("No forms returned\n"); - return False; - } + torture_assert(tctx, r.out.info, "No forms returned"); info = r.out.info; for (j = 0; j < r.out.count; j++) { - if (!print_server) ret &= test_GetForm(p, mem_ctx, handle, info[j].info1.form_name); + if (!print_server) + ret &= test_GetForm(tctx, p, handle, info[j].info1.form_name); } } - if (!NT_STATUS_IS_OK(status)) { - printf("EnumForms failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "EnumForms failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("EnumForms failed - %s\n", win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "EnumForms failed"); - return True; + return true; } -static BOOL test_DeleteForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DeleteForm(struct torture_context *tctx, + struct dcerpc_pipe *p, struct policy_handle *handle, const char *form_name) { @@ -962,29 +748,24 @@ static BOOL test_DeleteForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.handle = handle; r.in.form_name = form_name; - status = dcerpc_spoolss_DeleteForm(p, mem_ctx, &r); + status = dcerpc_spoolss_DeleteForm(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("DeleteForm failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "DeleteForm failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("DeleteForm failed - %s\n", win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "DeleteForm failed"); - return True; + return true; } -static BOOL test_AddForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, BOOL print_server) +static bool test_AddForm(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle, bool print_server) { struct spoolss_AddForm r; struct spoolss_AddFormInfo1 addform; const char *form_name = "testform3"; NTSTATUS status; - BOOL ret = True; + bool ret = true; r.in.handle = handle; r.in.level = 1; @@ -998,19 +779,13 @@ static BOOL test_AddForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, addform.area.right = 45; addform.area.bottom = 15; - status = dcerpc_spoolss_AddForm(p, mem_ctx, &r); + status = dcerpc_spoolss_AddForm(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("AddForm failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "AddForm failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("AddForm failed - %s\n", win_errstr(r.out.result)); - goto done; - } + torture_assert_werr_ok(tctx, r.out.result, "AddForm failed"); - if (!print_server) ret &= test_GetForm(p, mem_ctx, handle, form_name); + if (!print_server) ret &= test_GetForm(tctx, p, handle, form_name); { struct spoolss_SetForm sf; @@ -1027,92 +802,71 @@ static BOOL test_AddForm(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, setform.size.width = 1234; - status = dcerpc_spoolss_SetForm(p, mem_ctx, &sf); + status = dcerpc_spoolss_SetForm(p, tctx, &sf); - if (!NT_STATUS_IS_OK(status)) { - printf("SetForm failed - %s\n", nt_errstr(status)); - ret = False; - goto done; - } + torture_assert_ntstatus_ok(tctx, status, "SetForm failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("SetForm failed - %s\n", - win_errstr(r.out.result)); - ret = False; - goto done; - } + torture_assert_werr_ok(tctx, r.out.result, "SetForm failed"); } - if (!print_server) ret &= test_GetForm(p, mem_ctx, handle, form_name); + if (!print_server) ret &= test_GetForm(tctx, p, handle, form_name); - done: - if (!test_DeleteForm(p, mem_ctx, handle, form_name)) { - printf("DeleteForm failed\n"); - ret = False; + if (!test_DeleteForm(tctx, p, handle, form_name)) { + ret = false; } return ret; } -static BOOL test_EnumPorts_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_EnumPorts_old(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct spoolss_EnumPorts r; - r.in.servername = talloc_asprintf(mem_ctx, "\\\\%s", + r.in.servername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.level = 2; r.in.buffer = NULL; r.in.offered = 0; - printf("Testing EnumPorts\n"); + torture_comment(tctx, "Testing EnumPorts\n"); - status = dcerpc_spoolss_EnumPorts(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumPorts(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPorts failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "EnumPorts failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumPorts(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPorts failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_EnumPorts(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "EnumPorts failed"); - if (!r.out.info) { - printf("No ports returned\n"); - return False; - } + torture_assert(tctx, r.out.info, "No ports returned"); } - return True; + return true; } -static BOOL test_AddPort(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_AddPort(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct spoolss_AddPort r; - r.in.server_name = talloc_asprintf(mem_ctx, "\\\\%s", + r.in.server_name = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.unknown = 0; r.in.monitor_name = "foo"; - printf ("Testing AddPort\n"); + torture_comment(tctx, "Testing AddPort\n"); - status = dcerpc_spoolss_AddPort(p, mem_ctx, &r); + status = dcerpc_spoolss_AddPort(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("AddPort failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "AddPort failed"); /* win2k3 returns WERR_NOT_SUPPORTED */ @@ -1120,16 +874,17 @@ static BOOL test_AddPort(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) if (!W_ERROR_IS_OK(r.out.result)) { printf("AddPort failed - %s\n", win_errstr(r.out.result)); - return False; + return false; } #endif - return True; + return true; } -static BOOL test_GetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, uint32_t job_id) +static bool test_GetJob(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle, uint32_t job_id) { NTSTATUS status; struct spoolss_GetJob r; @@ -1140,33 +895,29 @@ static BOOL test_GetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.buffer = NULL; r.in.offered = 0; - printf("Testing GetJob\n"); + torture_comment(tctx, "Testing GetJob\n"); - status = dcerpc_spoolss_GetJob(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetJob failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_GetJob(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetJob failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_GetJob(p, mem_ctx, &r); + status = dcerpc_spoolss_GetJob(p, tctx, &r); - if (!r.out.info) { - printf("No job info returned\n"); - return False; - } + torture_assert(tctx, r.out.info, "No job info returned"); } - return True; + return true; } -static BOOL test_SetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle, uint32_t job_id, enum spoolss_JobControl command) +static bool test_SetJob(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle, uint32_t job_id, + enum spoolss_JobControl command) { NTSTATUS status; struct spoolss_SetJob r; @@ -1176,23 +927,18 @@ static BOOL test_SetJob(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.ctr = NULL; r.in.command = command; - printf("Testing SetJob\n"); + torture_comment(tctx, "Testing SetJob\n"); - status = dcerpc_spoolss_SetJob(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("SetJob failed - %s\n", nt_errstr(status)); - return False; - } - if (!W_ERROR_IS_OK(r.out.result)) { - printf("SetJob failed - %s\n", win_errstr(r.out.result)); - return False; - } + status = dcerpc_spoolss_SetJob(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "SetJob failed"); + torture_assert_werr_ok(tctx, r.out.result, "SetJob failed"); - return True; + return true; } -static BOOL test_EnumJobs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_EnumJobs(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) { NTSTATUS status; struct spoolss_EnumJobs r; @@ -1204,50 +950,44 @@ static BOOL test_EnumJobs(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.buffer = NULL; r.in.offered = 0; - printf("Testing EnumJobs\n"); + torture_comment(tctx, "Testing EnumJobs\n"); - status = dcerpc_spoolss_EnumJobs(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumJobs(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumJobs failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "EnumJobs failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { union spoolss_JobInfo *info; int j; - DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumJobs(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumJobs(p, tctx, &r); - if (!r.out.info) { - printf("No jobs returned\n"); - return True; - } + torture_assert(tctx, r.out.info, "No jobs returned"); info = r.out.info; for (j = 0; j < r.out.count; j++) { - test_GetJob(p, mem_ctx, handle, info[j].info1.job_id); - test_SetJob(p, mem_ctx, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_PAUSE); - test_SetJob(p, mem_ctx, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_RESUME); + test_GetJob(tctx, p, handle, info[j].info1.job_id); + test_SetJob(tctx, p, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_PAUSE); + test_SetJob(tctx, p, handle, info[j].info1.job_id, SPOOLSS_JOB_CONTROL_RESUME); } - } else if (!W_ERROR_IS_OK(r.out.result)) { - printf("EnumJobs failed - %s\n", win_errstr(r.out.result)); - return False; + } else { + torture_assert_werr_ok(tctx, r.out.result, "EnumJobs failed"); } - return True; + return true; } -static BOOL test_DoPrintTest(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_DoPrintTest(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) { - BOOL ret = True; + bool ret = true; NTSTATUS status; struct spoolss_StartDocPrinter s; struct spoolss_DocumentInfo1 info1; @@ -1258,7 +998,7 @@ static BOOL test_DoPrintTest(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, int i; uint32_t job_id; - printf("Testing StartDocPrinter\n"); + torture_comment(tctx, "Testing StartDocPrinter\n"); s.in.handle = handle; s.in.level = 1; @@ -1267,86 +1007,58 @@ static BOOL test_DoPrintTest(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, info1.output_file = NULL; info1.datatype = "RAW"; - status = dcerpc_spoolss_StartDocPrinter(p, mem_ctx, &s); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_StartDocPrinter failed - %s\n", nt_errstr(status)); - return False; - } - if (!W_ERROR_IS_OK(s.out.result)) { - printf("StartDocPrinter failed - %s\n", win_errstr(s.out.result)); - return False; - } + status = dcerpc_spoolss_StartDocPrinter(p, tctx, &s); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_StartDocPrinter failed"); + torture_assert_werr_ok(tctx, s.out.result, "StartDocPrinter failed"); job_id = s.out.job_id; for (i=1; i < 4; i++) { - printf("Testing StartPagePrinter: Page[%d]\n", i); + torture_comment(tctx, "Testing StartPagePrinter: Page[%d]\n", i); sp.in.handle = handle; - status = dcerpc_spoolss_StartPagePrinter(p, mem_ctx, &sp); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_StartPagePrinter failed - %s\n", nt_errstr(status)); - return False; - } - if (!W_ERROR_IS_OK(sp.out.result)) { - printf("StartPagePrinter failed - %s\n", win_errstr(sp.out.result)); - return False; - } + status = dcerpc_spoolss_StartPagePrinter(p, tctx, &sp); + torture_assert_ntstatus_ok(tctx, status, + "dcerpc_spoolss_StartPagePrinter failed"); + torture_assert_werr_ok(tctx, sp.out.result, "StartPagePrinter failed"); - printf("Testing WritePrinter: Page[%d]\n", i); + torture_comment(tctx, "Testing WritePrinter: Page[%d]\n", i); w.in.handle = handle; - w.in.data = data_blob_string_const(talloc_asprintf(mem_ctx,"TortureTestPage: %d\nData\n",i)); + w.in.data = data_blob_string_const(talloc_asprintf(tctx,"TortureTestPage: %d\nData\n",i)); - status = dcerpc_spoolss_WritePrinter(p, mem_ctx, &w); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_WritePrinter failed - %s\n", nt_errstr(status)); - return False; - } - if (!W_ERROR_IS_OK(w.out.result)) { - printf("WritePrinter failed - %s\n", win_errstr(w.out.result)); - return False; - } + status = dcerpc_spoolss_WritePrinter(p, tctx, &w); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_WritePrinter failed"); + torture_assert_werr_ok(tctx, w.out.result, "WritePrinter failed"); - printf("Testing EndPagePrinter: Page[%d]\n", i); + torture_comment(tctx, "Testing EndPagePrinter: Page[%d]\n", i); ep.in.handle = handle; - status = dcerpc_spoolss_EndPagePrinter(p, mem_ctx, &ep); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EndPagePrinter failed - %s\n", nt_errstr(status)); - return False; - } - if (!W_ERROR_IS_OK(ep.out.result)) { - printf("EndPagePrinter failed - %s\n", win_errstr(ep.out.result)); - return False; - } + status = dcerpc_spoolss_EndPagePrinter(p, tctx, &ep); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EndPagePrinter failed"); + torture_assert_werr_ok(tctx, ep.out.result, "EndPagePrinter failed"); } - printf("Testing EndDocPrinter\n"); + torture_comment(tctx, "Testing EndDocPrinter\n"); e.in.handle = handle; - status = dcerpc_spoolss_EndDocPrinter(p, mem_ctx, &e); - if (!NT_STATUS_IS_OK(status)) { - printf("dcerpc_spoolss_EndDocPrinter failed - %s\n", nt_errstr(status)); - return False; - } - if (!W_ERROR_IS_OK(e.out.result)) { - printf("EndDocPrinter failed - %s\n", win_errstr(e.out.result)); - return False; - } + status = dcerpc_spoolss_EndDocPrinter(p, tctx, &e); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_spoolss_EndDocPrinter failed"); + torture_assert_werr_ok(tctx, e.out.result, "EndDocPrinter failed"); - ret &= test_EnumJobs(p, mem_ctx, handle); + ret &= test_EnumJobs(tctx, p, handle); - ret &= test_SetJob(p, mem_ctx, handle, job_id, SPOOLSS_JOB_CONTROL_DELETE); + ret &= test_SetJob(tctx, p, handle, job_id, SPOOLSS_JOB_CONTROL_DELETE); return ret; } -static BOOL test_PausePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_PausePrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) { NTSTATUS status; struct spoolss_SetPrinter r; @@ -1358,25 +1070,20 @@ static BOOL test_PausePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.secdesc_ctr.sd = NULL; r.in.command = SPOOLSS_PRINTER_CONTROL_PAUSE; - printf("Testing SetPrinter: SPOOLSS_PRINTER_CONTROL_PAUSE\n"); + torture_comment(tctx, "Testing SetPrinter: SPOOLSS_PRINTER_CONTROL_PAUSE\n"); - status = dcerpc_spoolss_SetPrinter(p, mem_ctx, &r); + status = dcerpc_spoolss_SetPrinter(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("SetPrinter failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "SetPrinter failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("SetPrinter failed - %s\n", win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "SetPrinter failed"); - return True; + return true; } -static BOOL test_ResumePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_ResumePrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) { NTSTATUS status; struct spoolss_SetPrinter r; @@ -1388,24 +1095,19 @@ static BOOL test_ResumePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.secdesc_ctr.sd = NULL; r.in.command = SPOOLSS_PRINTER_CONTROL_RESUME; - printf("Testing SetPrinter: SPOOLSS_PRINTER_CONTROL_RESUME\n"); + torture_comment(tctx, "Testing SetPrinter: SPOOLSS_PRINTER_CONTROL_RESUME\n"); - status = dcerpc_spoolss_SetPrinter(p, mem_ctx, &r); + status = dcerpc_spoolss_SetPrinter(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("SetPrinter failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "SetPrinter failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("SetPrinter failed - %s\n", win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "SetPrinter failed"); - return True; + return true; } -static BOOL test_GetPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetPrinterData(struct torture_context *tctx, + struct dcerpc_pipe *p, struct policy_handle *handle, const char *value_name) { @@ -1416,35 +1118,25 @@ static BOOL test_GetPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.value_name = value_name; r.in.offered = 0; - printf("Testing GetPrinterData\n"); + torture_comment(tctx, "Testing GetPrinterData\n"); - status = dcerpc_spoolss_GetPrinterData(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetPrinterData failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_GetPrinterData(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed"); if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) { r.in.offered = r.out.needed; - status = dcerpc_spoolss_GetPrinterData(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetPrinterData failed - %s\n", - nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_GetPrinterData(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetPrinterData failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("GetPrinterData failed - %s\n", - win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "GetPrinterData failed"); } - return True; + return true; } -static BOOL test_GetPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetPrinterDataEx(struct torture_context *tctx, + struct dcerpc_pipe *p, struct policy_handle *handle, const char *key_name, const char *value_name) @@ -1457,40 +1149,30 @@ static BOOL test_GetPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.value_name = value_name; r.in.offered = 0; - printf("Testing GetPrinterDataEx\n"); + torture_comment(tctx, "Testing GetPrinterDataEx\n"); - status = dcerpc_spoolss_GetPrinterDataEx(p, mem_ctx, &r); + status = dcerpc_spoolss_GetPrinterDataEx(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { if (NT_STATUS_EQUAL(status,NT_STATUS_NET_WRITE_FAULT) && p->last_fault_code == DCERPC_FAULT_OP_RNG_ERROR) { - printf("GetPrinterDataEx not supported by server\n"); - return True; + torture_skip(tctx, "GetPrinterDataEx not supported by server\n"); } - printf("GetPrinterDataEx failed - %s\n", nt_errstr(status)); - return False; + torture_assert_ntstatus_ok(tctx, status, "GetPrinterDataEx failed"); } if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) { r.in.offered = r.out.needed; - status = dcerpc_spoolss_GetPrinterDataEx(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetPrinterDataEx failed - %s\n", - nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_GetPrinterDataEx(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetPrinterDataEx failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("GetPrinterDataEx failed - %s\n", - win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "GetPrinterDataEx failed"); } - return True; + return true; } -static BOOL test_EnumPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_EnumPrinterData(struct torture_context *tctx, struct dcerpc_pipe *p, struct policy_handle *handle) { NTSTATUS status; @@ -1507,38 +1189,33 @@ static BOOL test_EnumPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.data_size = &data_size; r.out.data_size = &data_size; - printf("Testing EnumPrinterData\n"); + torture_comment(tctx, "Testing EnumPrinterData\n"); - status = dcerpc_spoolss_EnumPrinterData(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumPrinterData(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrinterData failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "EnumPrinterData failed"); r.in.value_offered = r.out.value_needed; - status = dcerpc_spoolss_EnumPrinterData(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumPrinterData(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrinterData failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "EnumPrinterData failed"); - test_GetPrinterData(p, mem_ctx, handle, r.out.value_name); + test_GetPrinterData(tctx, p, handle, r.out.value_name); - test_GetPrinterDataEx( - p, mem_ctx, handle, "PrinterDriverData", + test_GetPrinterDataEx(tctx, + p, handle, "PrinterDriverData", r.out.value_name); r.in.enum_index++; } while (W_ERROR_IS_OK(r.out.result)); - return True; + return true; } -static BOOL test_EnumPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_EnumPrinterDataEx(struct torture_context *tctx, + struct dcerpc_pipe *p, struct policy_handle *handle) { NTSTATUS status; @@ -1548,28 +1225,23 @@ static BOOL test_EnumPrinterDataEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.key_name = "PrinterDriverData"; r.in.offered = 0; - printf("Testing EnumPrinterDataEx\n"); + torture_comment(tctx, "Testing EnumPrinterDataEx\n"); - status = dcerpc_spoolss_EnumPrinterDataEx(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrinterDataEx failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed"); r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumPrinterDataEx(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumPrinterDataEx(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrinterDataEx failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDataEx failed"); - return True; + return true; } -static BOOL test_DeletePrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_DeletePrinterData(struct torture_context *tctx, + struct dcerpc_pipe *p, struct policy_handle *handle, const char *value_name) { @@ -1579,20 +1251,18 @@ static BOOL test_DeletePrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.handle = handle; r.in.value_name = value_name; - printf("Testing DeletePrinterData\n"); + torture_comment(tctx, "Testing DeletePrinterData\n"); - status = dcerpc_spoolss_DeletePrinterData(p, mem_ctx, &r); + status = dcerpc_spoolss_DeletePrinterData(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("DeletePrinterData failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "DeletePrinterData failed"); - return True; + return true; } -static BOOL test_SetPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_SetPrinterData(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) { NTSTATUS status; struct spoolss_SetPrinterData r; @@ -1603,84 +1273,69 @@ static BOOL test_SetPrinterData(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.type = SPOOLSS_PRINTER_DATA_TYPE_STRING; r.in.data.string = "dog"; - printf("Testing SetPrinterData\n"); + torture_comment(tctx, "Testing SetPrinterData\n"); - status = dcerpc_spoolss_SetPrinterData(p, mem_ctx, &r); + status = dcerpc_spoolss_SetPrinterData(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("SetPrinterData failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "SetPrinterData failed"); - if (!test_GetPrinterData(p, mem_ctx, handle, value_name)) { - return False; + if (!test_GetPrinterData(tctx, p, handle, value_name)) { + return false; } - if (!test_DeletePrinterData(p, mem_ctx, handle, value_name)) { - return False; + if (!test_DeletePrinterData(tctx, p, handle, value_name)) { + return false; } - return True; + return true; } -static BOOL test_SecondaryClosePrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_SecondaryClosePrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, struct policy_handle *handle) { NTSTATUS status; struct dcerpc_binding *b; struct dcerpc_pipe *p2; - BOOL ret = True; + bool ret = true; /* only makes sense on SMB */ if (p->conn->transport.transport != NCACN_NP) { - return True; + return true; } - printf("testing close on secondary pipe\n"); + torture_comment(tctx, "testing close on secondary pipe\n"); - status = dcerpc_parse_binding(mem_ctx, p->conn->binding_string, &b); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to parse dcerpc binding '%s'\n", p->conn->binding_string); - return False; - } + status = dcerpc_parse_binding(tctx, p->conn->binding_string, &b); + torture_assert_ntstatus_ok(tctx, status, "Failed to parse dcerpc binding"); status = dcerpc_secondary_connection(p, &p2, b); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to create secondary connection\n"); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "Failed to create secondary connection"); status = dcerpc_bind_auth_none(p2, &ndr_table_spoolss); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to create bind on secondary connection\n"); - talloc_free(p2); - - return False; - } + torture_assert_ntstatus_ok(tctx, status, "Failed to create bind on secondary connection"); - if (test_ClosePrinter(p2, mem_ctx, handle)) { - printf("ERROR: Allowed close on secondary connection!\n"); - ret = False; + if (test_ClosePrinter(tctx, p2, handle)) { + torture_comment(tctx, "ERROR: Allowed close on secondary connection!\n"); + ret = false; } - if (p2->last_fault_code != DCERPC_FAULT_CONTEXT_MISMATCH) { - printf("Unexpected fault code 0x%x - expected 0x%x\n", - p2->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH); - ret = False; - } + torture_assert_int_equal(tctx, p2->last_fault_code, DCERPC_FAULT_CONTEXT_MISMATCH, + "Unexpected fault code"); talloc_free(p2); - return ret; + return true; } -static BOOL test_OpenPrinter_badname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *name) +static bool test_OpenPrinter_badname(struct torture_context *tctx, + struct dcerpc_pipe *p, const char *name) { NTSTATUS status; struct spoolss_OpenPrinter op; struct spoolss_OpenPrinterEx opEx; struct policy_handle handle; - BOOL ret = True; + bool ret = true; op.in.printername = name; op.in.datatype = NULL; @@ -1688,20 +1343,17 @@ static BOOL test_OpenPrinter_badname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, op.in.access_mask = 0; op.out.handle = &handle; - printf("\nTesting OpenPrinter(%s) with bad name\n", op.in.printername); + torture_comment(tctx, "\nTesting OpenPrinter(%s) with bad name\n", op.in.printername); - status = dcerpc_spoolss_OpenPrinter(p, mem_ctx, &op); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenPrinter failed - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_spoolss_OpenPrinter(p, tctx, &op); + torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed"); if (!W_ERROR_EQUAL(WERR_INVALID_PRINTER_NAME,op.out.result)) { - printf("OpenPrinter(%s) unexpected result[%s] should be WERR_INVALID_PRINTER_NAME\n", + torture_comment(tctx, "OpenPrinter(%s) unexpected result[%s] should be WERR_INVALID_PRINTER_NAME\n", name, win_errstr(op.out.result)); } if (W_ERROR_IS_OK(op.out.result)) { - ret &=test_ClosePrinter(p, mem_ctx, &handle); + ret &=test_ClosePrinter(tctx, p, &handle); } opEx.in.printername = name; @@ -1712,91 +1364,62 @@ static BOOL test_OpenPrinter_badname(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, opEx.in.userlevel.level1 = NULL; opEx.out.handle = &handle; - printf("\nTesting OpenPrinterEx(%s) with bad name\n", opEx.in.printername); + torture_comment(tctx, "Testing OpenPrinterEx(%s) with bad name\n", opEx.in.printername); - status = dcerpc_spoolss_OpenPrinterEx(p, mem_ctx, &opEx); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenPrinter failed - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_spoolss_OpenPrinterEx(p, tctx, &opEx); + torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed"); if (!W_ERROR_EQUAL(WERR_INVALID_PRINTER_NAME,opEx.out.result)) { - printf("OpenPrinterEx(%s) unexpected result[%s] should be WERR_INVALID_PRINTER_NAME\n", + torture_comment(tctx, "OpenPrinterEx(%s) unexpected result[%s] should be WERR_INVALID_PRINTER_NAME\n", name, win_errstr(opEx.out.result)); } if (W_ERROR_IS_OK(opEx.out.result)) { - ret &=test_ClosePrinter(p, mem_ctx, &handle); + ret &=test_ClosePrinter(tctx, p, &handle); } return ret; } -static BOOL test_OpenPrinter_badnames(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) -{ - BOOL ret = True; - char *name; - - ret &= test_OpenPrinter_badname(p, mem_ctx, "__INVALID_PRINTER__"); - ret &= test_OpenPrinter_badname(p, mem_ctx, "\\\\__INVALID_HOST__"); - ret &= test_OpenPrinter_badname(p, mem_ctx, ""); - ret &= test_OpenPrinter_badname(p, mem_ctx, "\\\\\\"); - ret &= test_OpenPrinter_badname(p, mem_ctx, "\\\\\\__INVALID_PRINTER__"); - - name = talloc_asprintf(mem_ctx, "\\\\%s\\", dcerpc_server_name(p)); - ret &= test_OpenPrinter_badname(p, mem_ctx, name); - talloc_free(name); - - name = talloc_asprintf(mem_ctx, "\\\\%s\\__INVALID_PRINTER__", dcerpc_server_name(p)); - ret &= test_OpenPrinter_badname(p, mem_ctx, name); - talloc_free(name); - - return ret; -} - -static BOOL test_OpenPrinter(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_OpenPrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, const char *name) { NTSTATUS status; struct spoolss_OpenPrinter r; struct policy_handle handle; - BOOL ret = True; + bool ret = true; - r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s", dcerpc_server_name(p), name); + r.in.printername = talloc_asprintf(tctx, "\\\\%s\\%s", dcerpc_server_name(p), name); r.in.datatype = NULL; r.in.devmode_ctr.devmode= NULL; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r.out.handle = &handle; - printf("\nTesting OpenPrinter(%s)\n", r.in.printername); + torture_comment(tctx, "Testing OpenPrinter(%s)\n", r.in.printername); - status = dcerpc_spoolss_OpenPrinter(p, mem_ctx, &r); + status = dcerpc_spoolss_OpenPrinter(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenPrinter failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("OpenPrinter failed - %s\n", win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "OpenPrinter failed"); - if (!test_GetPrinter(p, mem_ctx, &handle)) { - ret = False; + if (!test_GetPrinter(tctx, p, &handle)) { + ret = false; } - if (!test_SecondaryClosePrinter(p, mem_ctx, &handle)) { - ret = False; + if (!test_SecondaryClosePrinter(tctx, p, &handle)) { + ret = false; } - if (!test_ClosePrinter(p, mem_ctx, &handle)) { - ret = False; + if (!test_ClosePrinter(tctx, p, &handle)) { + ret = false; } return ret; } -static BOOL call_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool call_OpenPrinterEx(struct torture_context *tctx, + struct dcerpc_pipe *p, const char *name, struct policy_handle *handle) { struct spoolss_OpenPrinterEx r; @@ -1804,10 +1427,10 @@ static BOOL call_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, NTSTATUS status; if (name && name[0]) { - r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s\\%s", + r.in.printername = talloc_asprintf(tctx, "\\\\%s\\%s", dcerpc_server_name(p), name); } else { - r.in.printername = talloc_asprintf(mem_ctx, "\\\\%s", + r.in.printername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); } @@ -1826,87 +1449,82 @@ static BOOL call_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, userlevel1.minor = 3; userlevel1.processor = 4; - printf("Testing OpenPrinterEx(%s)\n", r.in.printername); + torture_comment(tctx, "Testing OpenPrinterEx(%s)\n", r.in.printername); - status = dcerpc_spoolss_OpenPrinterEx(p, mem_ctx, &r); + status = dcerpc_spoolss_OpenPrinterEx(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("OpenPrinterEx failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "OpenPrinterEx failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("OpenPrinterEx failed - %s\n", win_errstr(r.out.result)); - return False; - } + torture_assert_werr_ok(tctx, r.out.result, "OpenPrinterEx failed"); - return True; + return true; } -static BOOL test_OpenPrinterEx(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_OpenPrinterEx(struct torture_context *tctx, + struct dcerpc_pipe *p, const char *name) { struct policy_handle handle; - BOOL ret = True; + bool ret = true; - if (!call_OpenPrinterEx(p, mem_ctx, name, &handle)) { - return False; + if (!call_OpenPrinterEx(tctx, p, name, &handle)) { + return false; } - if (!test_GetPrinter(p, mem_ctx, &handle)) { - ret = False; + if (!test_GetPrinter(tctx, p, &handle)) { + ret = false; } - if (!test_EnumForms(p, mem_ctx, &handle, False)) { - ret = False; + if (!test_EnumForms(tctx, p, &handle, false)) { + ret = false; } - if (!test_AddForm(p, mem_ctx, &handle, False)) { - ret = False; + if (!test_AddForm(tctx, p, &handle, false)) { + ret = false; } - if (!test_EnumPrinterData(p, mem_ctx, &handle)) { - ret = False; + if (!test_EnumPrinterData(tctx, p, &handle)) { + ret = false; } - if (!test_EnumPrinterDataEx(p, mem_ctx, &handle)) { - ret = False; + if (!test_EnumPrinterDataEx(tctx, p, &handle)) { + ret = false; } - if (!test_PausePrinter(p, mem_ctx, &handle)) { - ret = False; + if (!test_PausePrinter(tctx, p, &handle)) { + ret = false; } - if (!test_DoPrintTest(p, mem_ctx, &handle)) { - ret = False; + if (!test_DoPrintTest(tctx, p, &handle)) { + ret = false; } - if (!test_ResumePrinter(p, mem_ctx, &handle)) { - ret = False; + if (!test_ResumePrinter(tctx, p, &handle)) { + ret = false; } - if (!test_SetPrinterData(p, mem_ctx, &handle)) { - ret = False; + if (!test_SetPrinterData(tctx, p, &handle)) { + ret = false; } - if (!test_SecondaryClosePrinter(p, mem_ctx, &handle)) { - ret = False; + if (!test_SecondaryClosePrinter(tctx, p, &handle)) { + ret = false; } - if (!test_ClosePrinter(p, mem_ctx, &handle)) { - ret = False; + if (!test_ClosePrinter(tctx, p, &handle)) { + ret = false; } return ret; } -static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_EnumPrinters_old(struct torture_context *tctx, struct dcerpc_pipe *p) { struct spoolss_EnumPrinters r; NTSTATUS status; uint16_t levels[] = {1, 2, 4, 5}; int i; - BOOL ret = True; + bool ret = true; for (i=0;i<ARRAY_SIZE(levels);i++) { union spoolss_PrinterInfo *info; @@ -1918,38 +1536,26 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.in.buffer = NULL; r.in.offered = 0; - printf("\nTesting EnumPrinters level %u\n", r.in.level); + torture_comment(tctx, "Testing EnumPrinters level %u\n", r.in.level); - status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrinters failed - %s\n", nt_errstr(status)); - ret = False; - continue; - } + status = dcerpc_spoolss_EnumPrinters(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumPrinters(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumPrinters(p, tctx, &r); } - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrinters failed - %s\n", - nt_errstr(status)); - continue; - } + torture_assert_ntstatus_ok(tctx, status, "EnumPrinters failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("EnumPrinters failed - %s\n", - win_errstr(r.out.result)); - continue; - } + torture_assert_werr_ok(tctx, r.out.result, "EnumPrinters failed"); if (!r.out.info) { - printf("No printers returned\n"); - continue; + torture_comment(tctx, "No printers returned\n"); + return true; } info = r.out.info; @@ -1957,14 +1563,14 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) for (j=0;j<r.out.count;j++) { if (r.in.level == 1) { /* the names appear to be comma-separated name lists? */ - char *name = talloc_strdup(mem_ctx, info[j].info1.name); + char *name = talloc_strdup(tctx, info[j].info1.name); char *comma = strchr(name, ','); if (comma) *comma = 0; - if (!test_OpenPrinter(p, mem_ctx, name)) { - ret = False; + if (!test_OpenPrinter(tctx, p, name)) { + ret = false; } - if (!test_OpenPrinterEx(p, mem_ctx, name)) { - ret = False; + if (!test_OpenPrinterEx(tctx, p, name)) { + ret = false; } } } @@ -1974,7 +1580,7 @@ static BOOL test_EnumPrinters_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) } #if 0 -static BOOL test_GetPrinterDriver2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_GetPrinterDriver2(struct dcerpc_pipe *p, struct policy_handle *handle, const char *driver_name) { @@ -1991,134 +1597,163 @@ static BOOL test_GetPrinterDriver2(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, printf("Testing GetPrinterDriver2\n"); - status = dcerpc_spoolss_GetPrinterDriver2(p, mem_ctx, &r); + status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("GetPrinterDriver2 failed - %s\n", nt_errstr(status)); - return False; + return false; } if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { r.in.offered = r.out.needed; - status = dcerpc_spoolss_GetPrinterDriver2(p, mem_ctx, &r); + status = dcerpc_spoolss_GetPrinterDriver2(p, tctx, &r); } if (!NT_STATUS_IS_OK(status)) { printf("GetPrinterDriver2 failed - %s\n", nt_errstr(status)); - return False; + return false; } if (!W_ERROR_IS_OK(r.out.result)) { printf("GetPrinterDriver2 failed - %s\n", win_errstr(r.out.result)); - return False; + return false; } - return True; + return true; } #endif -static BOOL test_EnumPrinterDrivers_old(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_EnumPrinterDrivers_old(struct torture_context *tctx, + struct dcerpc_pipe *p) { struct spoolss_EnumPrinterDrivers r; NTSTATUS status; uint16_t levels[] = {1, 2, 3, 4, 5, 6}; int i; - BOOL ret = True; for (i=0;i<ARRAY_SIZE(levels);i++) { - r.in.server = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.environment = "Windows NT x86"; r.in.level = levels[i]; r.in.buffer = NULL; r.in.offered = 0; - printf("\nTesting EnumPrinterDrivers level %u\n", r.in.level); + torture_comment(tctx, "Testing EnumPrinterDrivers level %u\n", r.in.level); - status = dcerpc_spoolss_EnumPrinterDrivers(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumPrinterDrivers(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrinterDrivers failed - %s\n", - nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDrivers failed"); if (W_ERROR_EQUAL(r.out.result, WERR_INSUFFICIENT_BUFFER)) { - DATA_BLOB blob = data_blob_talloc(mem_ctx, NULL, r.out.needed); + DATA_BLOB blob = data_blob_talloc(tctx, NULL, r.out.needed); data_blob_clear(&blob); r.in.buffer = &blob; r.in.offered = r.out.needed; - status = dcerpc_spoolss_EnumPrinterDrivers(p, mem_ctx, &r); + status = dcerpc_spoolss_EnumPrinterDrivers(p, tctx, &r); } - if (!NT_STATUS_IS_OK(status)) { - printf("EnumPrinterDrivers failed - %s\n", - nt_errstr(status)); - ret = False; - break; - } + torture_assert_ntstatus_ok(tctx, status, "EnumPrinterDrivers failed"); - if (!W_ERROR_IS_OK(r.out.result)) { - printf("EnumPrinterDrivers failed - %s\n", - win_errstr(r.out.result)); - ret = False; - break; - } + torture_assert_werr_ok(tctx, r.out.result, "EnumPrinterDrivers failed"); if (!r.out.info) { - printf("No printer drivers returned\n"); + torture_comment(tctx, "No printer drivers returned\n"); break; } } - return ret; + return true; +} + +/** Test that makes sure that calling ReplyOpenPrinter() + * on Samba 4 will cause an irpc broadcast call. + */ +static bool test_ReplyOpenPrinter(struct torture_context *tctx, + struct dcerpc_pipe *pipe) +{ + struct spoolss_ReplyOpenPrinter r; + struct spoolss_ReplyClosePrinter s; + struct policy_handle h; + + r.in.server_name = "earth"; + r.in.printer_local = 2; + r.in.type = REG_DWORD; + r.in.unknown1 = 0; + r.in.unknown2 = 0; + r.out.handle = &h; + + torture_assert_ntstatus_ok(tctx, + dcerpc_spoolss_ReplyOpenPrinter(pipe, tctx, &r), + "spoolss_ReplyOpenPrinter call failed"); + + torture_assert_werr_ok(tctx, r.out.result, "error return code"); + + s.in.handle = &h; + s.out.handle = &h; + + torture_assert_ntstatus_ok(tctx, + dcerpc_spoolss_ReplyClosePrinter(pipe, tctx, &s), + "spoolss_ReplyClosePrinter call failed"); + + torture_assert_werr_ok(tctx, r.out.result, "error return code"); + + return true; } bool torture_rpc_spoolss(struct torture_context *torture) { - NTSTATUS status; - struct dcerpc_pipe *p; - BOOL ret = True; + NTSTATUS status; + struct dcerpc_pipe *p; + bool ret = true; struct test_spoolss_context *ctx; status = torture_rpc_connection(torture, &p, &ndr_table_spoolss); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } ctx = talloc_zero(torture, struct test_spoolss_context); - ctx->p = p; - - ret &= test_OpenPrinter_server(ctx); - - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "W3SvcInstalled"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "BeepEnabled"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "EventLog"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "NetPopup"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "NetPopupToComputer"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "MajorVersion"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "MinorVersion"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "DefaultSpoolDirectory"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "Architecture"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "DsPresent"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "OSVersion"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "OSVersionEx"); - ret &= test_GetPrinterData(ctx->p, ctx, &ctx->server_handle, "DNSMachineName"); - ret &= test_EnumForms(ctx->p, ctx, &ctx->server_handle, True); - ret &= test_AddForm(ctx->p, ctx, &ctx->server_handle, True); - ret &= test_EnumPorts(ctx); - ret &= test_GetPrinterDriverDirectory(ctx); - ret &= test_EnumPrinterDrivers(ctx); - ret &= test_EnumMonitors(ctx); - ret &= test_EnumPrintProcessors(ctx); - ret &= test_EnumPrinters(ctx); - ret &= test_OpenPrinter_badnames(p, torture); - ret &= test_AddPort(p, torture); - ret &= test_EnumPorts_old(p, torture); - ret &= test_EnumPrinters_old(p, torture); - ret &= test_EnumPrinterDrivers_old(p, torture); + + ret &= test_OpenPrinter_server(torture, p, ctx); + + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "W3SvcInstalled"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "BeepEnabled"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "EventLog"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "NetPopup"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "NetPopupToComputer"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "MajorVersion"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "MinorVersion"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "DefaultSpoolDirectory"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "Architecture"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "DsPresent"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "OSVersion"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "OSVersionEx"); + ret &= test_GetPrinterData(torture, p, &ctx->server_handle, "DNSMachineName"); + ret &= test_EnumForms(torture, p, &ctx->server_handle, true); + ret &= test_AddForm(torture, p, &ctx->server_handle, true); + ret &= test_EnumPorts(torture, p, ctx); + ret &= test_GetPrinterDriverDirectory(torture, p, ctx); + ret &= test_EnumPrinterDrivers(torture, p, ctx); + ret &= test_EnumMonitors(torture, p, ctx); + ret &= test_EnumPrintProcessors(torture, p, ctx); + ret &= test_EnumPrinters(torture, p, ctx); + ret &= test_OpenPrinter_badname(torture, p, "__INVALID_PRINTER__"); + ret &= test_OpenPrinter_badname(torture, p, "\\\\__INVALID_HOST__"); + ret &= test_OpenPrinter_badname(torture, p, ""); + ret &= test_OpenPrinter_badname(torture, p, "\\\\\\"); + ret &= test_OpenPrinter_badname(torture, p, "\\\\\\__INVALID_PRINTER__"); + ret &= test_OpenPrinter_badname(torture, p, talloc_asprintf(torture, "\\\\%s\\", dcerpc_server_name(p))); + ret &= test_OpenPrinter_badname(torture, p, + talloc_asprintf(torture, "\\\\%s\\__INVALID_PRINTER__", dcerpc_server_name(p))); + + + ret &= test_AddPort(torture, p); + ret &= test_EnumPorts_old(torture, p); + ret &= test_EnumPrinters_old(torture, p); + ret &= test_EnumPrinterDrivers_old(torture, p); + ret &= test_ReplyOpenPrinter(torture, p); return ret; } diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c new file mode 100644 index 0000000000..e44c2a874b --- /dev/null +++ b/source4/torture/rpc/spoolss_notify.c @@ -0,0 +1,296 @@ +/* + Unix SMB/CIFS implementation. + test suite for spoolss rpc notify operations + + Copyright (C) Jelmer Vernooij 2007 + + 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 2 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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "torture/torture.h" +#include "torture/ui.h" +#include "torture/rpc/rpc.h" +#include "librpc/gen_ndr/ndr_spoolss_c.h" +#include "rpc_server/dcerpc_server.h" +#include "lib/events/events.h" +#include "smbd/process_model.h" +#include "smb_server/smb_server.h" +#include "lib/socket/netif.h" +#include "dlinklist.h" +#include "ntvfs/ntvfs.h" +#include "param/param.h" + +static NTSTATUS spoolss__op_bind(struct dcesrv_call_state *dce_call, const struct dcesrv_interface *iface) +{ + return NT_STATUS_OK; +} + +static void spoolss__op_unbind(struct dcesrv_connection_context *context, const struct dcesrv_interface *iface) +{ +} + +static NTSTATUS spoolss__op_ndr_pull(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_pull *pull, void **r) +{ + NTSTATUS status; + uint16_t opnum = dce_call->pkt.u.request.opnum; + + dce_call->fault_code = 0; + + if (opnum >= ndr_table_spoolss.num_calls) { + dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR; + return NT_STATUS_NET_WRITE_FAULT; + } + + *r = talloc_size(mem_ctx, ndr_table_spoolss.calls[opnum].struct_size); + NT_STATUS_HAVE_NO_MEMORY(*r); + + /* unravel the NDR for the packet */ + status = ndr_table_spoolss.calls[opnum].ndr_pull(pull, NDR_IN, *r); + if (!NT_STATUS_IS_OK(status)) { + dcerpc_log_packet(&ndr_table_spoolss, opnum, NDR_IN, + &dce_call->pkt.u.request.stub_and_verifier); + dce_call->fault_code = DCERPC_FAULT_NDR; + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +/* FIXME: What context does this belong in ? -- JRV20070903 */ +static struct received_packet { + uint16_t opnum; + void *r; + struct received_packet *prev, *next; +} *received_packets = NULL; + + +static NTSTATUS spoolss__op_dispatch(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) +{ + uint16_t opnum = dce_call->pkt.u.request.opnum; + struct received_packet *rp; + + rp = talloc_zero(mem_ctx, struct received_packet); + rp->opnum = opnum; + rp->r = talloc_reference(mem_ctx, r); + + DLIST_ADD_END(received_packets, rp, struct received_packet *); + + switch (opnum) { + case 58: { + struct spoolss_ReplyOpenPrinter *r2 = (struct spoolss_ReplyOpenPrinter *)r; + r2->out.result = WERR_OK; + break; + } + + default: + dce_call->fault_code = DCERPC_FAULT_OP_RNG_ERROR; + break; + } + + if (dce_call->fault_code != 0) { + dcerpc_log_packet(&ndr_table_spoolss, opnum, NDR_IN, + &dce_call->pkt.u.request.stub_and_verifier); + return NT_STATUS_NET_WRITE_FAULT; + } + return NT_STATUS_OK; +} + + +static NTSTATUS spoolss__op_reply(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, void *r) +{ + return NT_STATUS_OK; +} + + +static NTSTATUS spoolss__op_ndr_push(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct ndr_push *push, const void *r) +{ + NTSTATUS status; + uint16_t opnum = dce_call->pkt.u.request.opnum; + + status = ndr_table_spoolss.calls[opnum].ndr_push(push, NDR_OUT, r); + if (!NT_STATUS_IS_OK(status)) { + dce_call->fault_code = DCERPC_FAULT_NDR; + return NT_STATUS_NET_WRITE_FAULT; + } + + return NT_STATUS_OK; +} + +const static struct dcesrv_interface notify_test_spoolss_interface = { + .name = "spoolss", + .syntax_id = {{0x12345678,0x1234,0xabcd,{0xef,0x00},{0x01,0x23,0x45,0x67,0x89,0xab}},1.0}, + .bind = spoolss__op_bind, + .unbind = spoolss__op_unbind, + .ndr_pull = spoolss__op_ndr_pull, + .dispatch = spoolss__op_dispatch, + .reply = spoolss__op_reply, + .ndr_push = spoolss__op_ndr_push +}; + +static bool spoolss__op_interface_by_uuid(struct dcesrv_interface *iface, const struct GUID *uuid, uint32_t if_version) +{ + if (notify_test_spoolss_interface.syntax_id.if_version == if_version && + GUID_equal(¬ify_test_spoolss_interface.syntax_id.uuid, uuid)) { + memcpy(iface,¬ify_test_spoolss_interface, sizeof(*iface)); + return true; + } + + return false; +} + +static bool spoolss__op_interface_by_name(struct dcesrv_interface *iface, const char *name) +{ + if (strcmp(notify_test_spoolss_interface.name, name)==0) { + memcpy(iface, ¬ify_test_spoolss_interface, sizeof(*iface)); + return true; + } + + return false; +} + +static NTSTATUS spoolss__op_init_server(struct dcesrv_context *dce_ctx, const struct dcesrv_endpoint_server *ep_server) +{ + int i; + + for (i=0;i<ndr_table_spoolss.endpoints->count;i++) { + NTSTATUS ret; + const char *name = ndr_table_spoolss.endpoints->names[i]; + + ret = dcesrv_interface_register(dce_ctx, name, ¬ify_test_spoolss_interface, NULL); + if (!NT_STATUS_IS_OK(ret)) { + DEBUG(1,("spoolss_op_init_server: failed to register endpoint '%s'\n",name)); + return ret; + } + } + + return NT_STATUS_OK; +} + +static bool test_RFFPCNEx(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + struct spoolss_OpenPrinter q; + struct spoolss_RemoteFindFirstPrinterChangeNotifyEx r; + struct dcesrv_endpoint_server ep_server; + NTSTATUS status; + struct dcesrv_context *dce_ctx; + const char *endpoints[] = { "spoolss", NULL }; + struct spoolss_NotifyOptionsContainer t1; + struct spoolss_ClosePrinter cp; + + struct policy_handle handle; + const char *address; + + ZERO_STRUCT(q); + + q.in.printername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + q.in.datatype = NULL; + q.in.devmode_ctr.devmode= NULL; + q.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + q.out.handle = &handle; + + torture_comment(tctx, "Testing OpenPrinter(%s)\n", q.in.printername); + + status = dcerpc_spoolss_OpenPrinter(p, tctx, &q); + + torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed"); + + torture_assert_werr_ok(tctx, q.out.result, "OpenPrinter failed"); + + /* Start DCE/RPC server */ + + /* fill in our name */ + ep_server.name = "spoolss"; + + /* fill in all the operations */ + ep_server.init_server = spoolss__op_init_server; + + ep_server.interface_by_uuid = spoolss__op_interface_by_uuid; + ep_server.interface_by_name = spoolss__op_interface_by_name; + + torture_assert_ntstatus_ok(tctx, dcerpc_register_ep_server(&ep_server), + "unable to register spoolss server"); + + lp_set_cmdline(global_loadparm, "dcerpc endpoint servers", "spoolss"); + + address = iface_n_ip(0); + torture_comment(tctx, "Listening for callbacks on %s\n", address); + status = smbsrv_add_socket(p->conn->event_ctx, &single_ops, address); + torture_assert_ntstatus_ok(tctx, status, "starting smb server"); + + status = dcesrv_init_context(tctx, endpoints, &dce_ctx); + torture_assert_ntstatus_ok(tctx, status, + "unable to initialize DCE/RPC server"); + + + r.in.flags = 0; + r.in.str = talloc_asprintf(tctx, "\\\\%s", address); + r.in.options = 0; + r.in.printer_local = 123; + t1.version = 2; + t1.flags = 0; + t1.count = 2; + t1.options = talloc_zero_array(tctx, struct spoolss_NotifyOptionsArray, 2); + t1.options[0].type = SPOOLSS_NOTIFY_PRINTER; + t1.options[0].count = 1; + t1.options[0].fields = talloc_array(t1.options, enum spoolss_Field, 1); + t1.options[0].fields[0] = SPOOLSS_FIELD_SERVER_NAME; + + t1.options[1].type = SPOOLSS_NOTIFY_JOB; + t1.options[1].count = 1; + t1.options[1].fields = talloc_array(t1.options, enum spoolss_Field, 1); + t1.options[1].fields[0] = SPOOLSS_FIELD_PRINTER_NAME; + + r.in.t1 = &t1; + r.in.handle = &handle; + + + status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(p, tctx, &r); + + torture_assert_ntstatus_ok(tctx, status, "FFPCNEx failed"); + + torture_assert_werr_ok(tctx, r.out.result, "error return code for FFPCNEx"); + + cp.in.handle = &handle; + cp.out.handle = &handle; + + torture_comment(tctx, "Testing ClosePrinter\n"); + + status = dcerpc_spoolss_ClosePrinter(p, tctx, &cp); + torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed"); + + /* We should've had an incoming packet 58 (ReplyOpenPrinter) */ + torture_assert(tctx, received_packets != NULL, "no packets received"); + torture_assert_int_equal(tctx, received_packets->opnum, 58, "invalid opnum"); + + /* Shut down DCE/RPC server */ + talloc_free(dce_ctx); + + return true; +} + +struct torture_suite *torture_rpc_spoolss_notify(TALLOC_CTX *mem_ctx) +{ + struct torture_suite *suite = torture_suite_create(mem_ctx, "SPOOLSS-NOTIFY"); + + struct torture_rpc_tcase *tcase = torture_suite_add_rpc_iface_tcase(suite, + "notify", &ndr_table_spoolss); + + ntvfs_init(); + torture_rpc_tcase_add_test(tcase, "testRFFPCNEx", test_RFFPCNEx); + + return suite; +} diff --git a/source4/torture/rpc/srvsvc.c b/source4/torture/rpc/srvsvc.c index a51dc96876..1fe1221b0d 100644 --- a/source4/torture/rpc/srvsvc.c +++ b/source4/torture/rpc/srvsvc.c @@ -27,70 +27,52 @@ /**************************/ /* srvsvc_NetCharDev */ /**************************/ -static BOOL test_NetCharDevGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_NetCharDevGetInfo(struct dcerpc_pipe *p, struct torture_context *tctx, const char *devname) { NTSTATUS status; struct srvsvc_NetCharDevGetInfo r; uint32_t levels[] = {0, 1}; int i; - BOOL ret = True; - r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.device_name = devname; for (i=0;i<ARRAY_SIZE(levels);i++) { ZERO_STRUCT(r.out); r.in.level = levels[i]; - d_printf("testing NetCharDevGetInfo level %u on device '%s'\n", + torture_comment(tctx, "testing NetCharDevGetInfo level %u on device '%s'\n", r.in.level, r.in.device_name); - status = dcerpc_srvsvc_NetCharDevGetInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetCharDevGetInfo level %u on device '%s' failed - %s\n", - r.in.level, r.in.device_name, nt_errstr(status)); - ret = False; - continue; - } - if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetCharDevGetInfo level %u on device '%s' failed - %s\n", - r.in.level, r.in.device_name, win_errstr(r.out.result)); - continue; - } + status = dcerpc_srvsvc_NetCharDevGetInfo(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "NetCharDevGetInfo failed"); + torture_assert_werr_ok(tctx, r.out.result, "NetCharDevGetInfo failed"); } - return ret; + return true; } -static BOOL test_NetCharDevControl(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_NetCharDevControl(struct dcerpc_pipe *p, struct torture_context *tctx, const char *devname) { NTSTATUS status; struct srvsvc_NetCharDevControl r; uint32_t opcodes[] = {0, 1}; int i; - BOOL ret = True; - r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.device_name = devname; for (i=0;i<ARRAY_SIZE(opcodes);i++) { ZERO_STRUCT(r.out); r.in.opcode = opcodes[i]; - d_printf("testing NetCharDevControl opcode %u on device '%s'\n", + torture_comment(tctx, "testing NetCharDevControl opcode %u on device '%s'\n", r.in.opcode, r.in.device_name); - status = dcerpc_srvsvc_NetCharDevControl(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetCharDevControl opcode %u failed - %s\n", r.in.opcode, nt_errstr(status)); - ret = False; - continue; - } - if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetCharDevControl opcode %u failed - %s\n", r.in.opcode, win_errstr(r.out.result)); - continue; - } + status = dcerpc_srvsvc_NetCharDevControl(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "NetCharDevControl failed"); + torture_assert_werr_ok(tctx, r.out.result, "NetCharDevControl failed"); } - return ret; + return true; } static bool test_NetCharDevEnum(struct torture_context *tctx, @@ -101,7 +83,6 @@ static bool test_NetCharDevEnum(struct torture_context *tctx, struct srvsvc_NetCharDevCtr0 c0; uint32_t levels[] = {0, 1}; int i; - BOOL ret = True; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.ctr.ctr0 = &c0; @@ -113,18 +94,13 @@ static bool test_NetCharDevEnum(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { int j; - ZERO_STRUCT(r.out); r.in.level = levels[i]; - printf("testing NetCharDevEnum level %u\n", r.in.level); + torture_comment(tctx, "testing NetCharDevEnum level %u\n", r.in.level); status = dcerpc_srvsvc_NetCharDevEnum(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetCharDevEnum level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetCharDevEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetCharDevEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result)); + torture_comment(tctx, "NetCharDevEnum failed: %s\n", win_errstr(r.out.result)); continue; } @@ -134,58 +110,48 @@ static bool test_NetCharDevEnum(struct torture_context *tctx, const char *device; device = r.out.ctr.ctr1->array[j].device; if (!test_NetCharDevGetInfo(p, tctx, device)) { - ret = False; + return false; } if (!test_NetCharDevControl(p, tctx, device)) { - ret = False; + return false; } } } } - return ret; + return true; } /**************************/ /* srvsvc_NetCharDevQ */ /**************************/ -static BOOL test_NetCharDevQGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_NetCharDevQGetInfo(struct dcerpc_pipe *p, struct torture_context *tctx, const char *devicequeue) { NTSTATUS status; struct srvsvc_NetCharDevQGetInfo r; uint32_t levels[] = {0, 1}; int i; - BOOL ret = True; - r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.queue_name = devicequeue; - r.in.user = talloc_asprintf(mem_ctx,"Administrator"); + r.in.user = talloc_asprintf(tctx,"Administrator"); for (i=0;i<ARRAY_SIZE(levels);i++) { ZERO_STRUCT(r.out); r.in.level = levels[i]; - d_printf("testing NetCharDevQGetInfo level %u on devicequeue '%s'\n", + torture_comment(tctx, "testing NetCharDevQGetInfo level %u on devicequeue '%s'\n", r.in.level, r.in.queue_name); - status = dcerpc_srvsvc_NetCharDevQGetInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetCharDevQGetInfo level %u on devicequeue '%s' failed - %s\n", - r.in.level, r.in.queue_name, nt_errstr(status)); - ret = False; - continue; - } - if (!W_ERROR_IS_OK(r.out.result)) { - printf("NetCharDevQGetInfo level %u on devicequeue '%s' failed - %s\n", - r.in.level, r.in.queue_name, win_errstr(r.out.result)); - continue; - } + status = dcerpc_srvsvc_NetCharDevQGetInfo(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "NetCharDevQGetInfo failed"); + torture_assert_werr_ok(tctx, r.out.result, "NetCharDevQGetInfo failed"); } - return ret; + return true; } #if 0 -static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *devicequeue) { NTSTATUS status; @@ -193,7 +159,7 @@ static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint32_t parm_error; uint32_t levels[] = {0, 1}; int i; - BOOL ret = True; + bool ret = true; r.in.server_unc = talloc_asprintf(mem_ctx,"\\\\%s",dcerpc_server_name(p)); r.in.queue_name = devicequeue; @@ -225,7 +191,7 @@ static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, if (!NT_STATUS_IS_OK(status)) { d_printf("NetCharDevQSetInfo level %u on devicequeue '%s' failed - %s\n", r.in.level, r.in.queue_name, nt_errstr(status)); - ret = False; + ret = false; continue; } if (!W_ERROR_IS_OK(r.out.result)) { @@ -239,15 +205,14 @@ static BOOL test_NetCharDevQSetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, } #endif -static BOOL test_NetCharDevQEnum(struct torture_context *tctx, - struct dcerpc_pipe *p) +static bool test_NetCharDevQEnum(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct srvsvc_NetCharDevQEnum r; struct srvsvc_NetCharDevQCtr0 c0; uint32_t levels[] = {0, 1}; int i; - BOOL ret = True; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.user = talloc_asprintf(tctx,"%s","Administrator"); @@ -262,15 +227,11 @@ static BOOL test_NetCharDevQEnum(struct torture_context *tctx, ZERO_STRUCT(r.out); r.in.level = levels[i]; - printf("testing NetCharDevQEnum level %u\n", r.in.level); + torture_comment(tctx, "testing NetCharDevQEnum level %u\n", r.in.level); status = dcerpc_srvsvc_NetCharDevQEnum(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetCharDevQEnum level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetCharDevQEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetCharDevQEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result)); + torture_comment(tctx, "NetCharDevQEnum failed: %s\n", win_errstr(r.out.result)); continue; } @@ -280,27 +241,26 @@ static BOOL test_NetCharDevQEnum(struct torture_context *tctx, const char *device; device = r.out.ctr.ctr1->array[j].device; if (!test_NetCharDevQGetInfo(p, tctx, device)) { - ret = False; + return false; } } } } - return ret; + return true; } /**************************/ /* srvsvc_NetConn */ /**************************/ -static BOOL test_NetConnEnum(struct torture_context *tctx, - struct dcerpc_pipe *p) +static bool test_NetConnEnum(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct srvsvc_NetConnEnum r; struct srvsvc_NetConnCtr0 c0; uint32_t levels[] = {0, 1}; int i; - BOOL ret = True; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.path = talloc_asprintf(tctx,"%s","ADMIN$"); @@ -313,34 +273,28 @@ static BOOL test_NetConnEnum(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { ZERO_STRUCT(r.out); r.in.level = levels[i]; - d_printf("testing NetConnEnum level %u\n", r.in.level); + torture_comment(tctx, "testing NetConnEnum level %u\n", r.in.level); status = dcerpc_srvsvc_NetConnEnum(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetConnEnum level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetConnEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetConnEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result)); - continue; + torture_comment(tctx, "NetConnEnum failed: %s\n", win_errstr(r.out.result)); } } - return ret; + return true; } /**************************/ /* srvsvc_NetFile */ /**************************/ -static BOOL test_NetFileEnum(struct torture_context *tctx, - struct dcerpc_pipe *p) +static bool test_NetFileEnum(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct srvsvc_NetFileEnum r; struct srvsvc_NetFileCtr3 c3; uint32_t levels[] = {2, 3}; int i; - BOOL ret = True; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.path = NULL; @@ -354,34 +308,28 @@ static BOOL test_NetFileEnum(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { ZERO_STRUCT(r.out); r.in.level = levels[i]; - d_printf("testing NetFileEnum level %u\n", r.in.level); + torture_comment(tctx, "testing NetFileEnum level %u\n", r.in.level); status = dcerpc_srvsvc_NetFileEnum(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetFileEnum level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetFileEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetFileEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result)); - continue; + torture_comment(tctx, "NetFileEnum failed: %s\n", win_errstr(r.out.result)); } } - return ret; + return true; } /**************************/ /* srvsvc_NetSess */ /**************************/ -static BOOL test_NetSessEnum(struct torture_context *tctx, - struct dcerpc_pipe *p) +static bool test_NetSessEnum(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct srvsvc_NetSessEnum r; struct srvsvc_NetSessCtr0 c0; uint32_t levels[] = {0, 1, 2, 10, 502}; int i; - BOOL ret = True; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.client = NULL; @@ -395,49 +343,37 @@ static BOOL test_NetSessEnum(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { ZERO_STRUCT(r.out); r.in.level = levels[i]; - d_printf("testing NetSessEnum level %u\n", r.in.level); + torture_comment(tctx, "testing NetSessEnum level %u\n", r.in.level); status = dcerpc_srvsvc_NetSessEnum(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetSessEnum level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetSessEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetSessEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result)); - continue; + torture_comment(tctx, "NetSessEnum failed: %s\n", win_errstr(r.out.result)); } } - return ret; + return true; } /**************************/ /* srvsvc_NetShare */ /**************************/ -static BOOL test_NetShareCheck(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, +static bool test_NetShareCheck(struct dcerpc_pipe *p, struct torture_context *tctx, const char *device_name) { NTSTATUS status; struct srvsvc_NetShareCheck r; - BOOL ret = True; - r.in.server_unc = talloc_asprintf(mem_ctx, "\\\\%s", dcerpc_server_name(p)); + r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.device_name = device_name; - d_printf("testing NetShareCheck on device '%s'\n", r.in.device_name); - - status = dcerpc_srvsvc_NetShareCheck(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("dcerpc_srvsvc_NetShareCheck on device '%s' failed - %s\n", - r.in.device_name, nt_errstr(status)); - ret = False; - } else if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetShareCheck on device '%s' failed - %s\n", - r.in.device_name, win_errstr(r.out.result)); - ret = False; - } + torture_comment(tctx, + "testing NetShareCheck on device '%s'\n", r.in.device_name); - return ret; + status = dcerpc_srvsvc_NetShareCheck(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "dcerpc_srvsvc_NetShareCheck failed"); + torture_assert_werr_ok(tctx, r.out.result, "NetShareCheck failed"); + + return true; } static bool test_NetShareGetInfo(struct torture_context *tctx, @@ -459,7 +395,6 @@ static bool test_NetShareGetInfo(struct torture_context *tctx, { 1005, WERR_OK, WERR_OK }, }; int i; - BOOL ret = True; r.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); r.in.share_name = sharename; @@ -472,32 +407,21 @@ static bool test_NetShareGetInfo(struct torture_context *tctx, if (admin) expected = levels[i].admin_status; ZERO_STRUCT(r.out); - d_printf("testing NetShareGetInfo level %u on share '%s'\n", + torture_comment(tctx, "testing NetShareGetInfo level %u on share '%s'\n", r.in.level, r.in.share_name); status = dcerpc_srvsvc_NetShareGetInfo(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n", - r.in.level, r.in.share_name, nt_errstr(status)); - ret = False; - continue; - } - if (!W_ERROR_EQUAL(r.out.result, expected)) { - d_printf("NetShareGetInfo level %u on share '%s' failed - %s (expected %s)\n", - r.in.level, r.in.share_name, win_errstr(r.out.result), - win_errstr(expected)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetShareGetInfo failed"); + torture_assert_werr_equal(tctx, r.out.result, expected, "NetShareGetInfo failed"); if (r.in.level != 2) continue; if (!r.out.info.info2 || !r.out.info.info2->path) continue; if (!test_NetShareCheck(p, tctx, r.out.info.info2->path)) { - ret = False; + return false; } } - return ret; + return true; } static bool test_NetShareGetInfoAdminFull(struct torture_context *tctx, @@ -536,11 +460,6 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx, { 1501, WERR_OK }, }; int i; - BOOL ret = True; - - if (!torture_setting_bool(tctx, "dangerous", false)) - torture_skip(tctx, - "NetShareAddSetDel disabled - enable dangerous tests to use\n"); a.in.server_unc = r.in.server_unc = q.in.server_unc = d.in.server_unc = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); @@ -560,15 +479,8 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx, a.in.parm_error = NULL; status = dcerpc_srvsvc_NetShareAdd(p, tctx, &a); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetShareAdd level 2 on share 'testshare' failed - %s\n", - nt_errstr(status)); - return False; - } else if (!W_ERROR_EQUAL(a.out.result, WERR_OK)) { - d_printf("NetShareAdd level 2 on share 'testshare' failed - %s\n", - win_errstr(a.out.result)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "NetShareAdd level 2 on share 'testshare' failed"); + torture_assert_werr_ok(tctx, a.out.result, "NetShareAdd level 2 on share 'testshare' failed"); r.in.parm_error = NULL; @@ -579,7 +491,7 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx, r.in.level = levels[i].level; ZERO_STRUCT(r.out); - d_printf("testing NetShareSetInfo level %u on share '%s'\n", + torture_comment(tctx, "testing NetShareSetInfo level %u on share '%s'\n", r.in.level, r.in.share_name); switch (levels[i].level) { @@ -648,73 +560,45 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx, } status = dcerpc_srvsvc_NetShareSetInfo(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n", - r.in.level, r.in.share_name, nt_errstr(status)); - ret = False; - continue; - } else if (!W_ERROR_EQUAL(r.out.result, levels[i].expected)) { - d_printf("NetShareSetInfo level %u on share '%s' failed - %s (expected %s)\n", - r.in.level, r.in.share_name, win_errstr(r.out.result), - win_errstr(levels[i].expected)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetShareGetInfo failed"); + torture_assert_werr_equal(tctx, r.out.result, levels[i].expected, "NetShareSetInfo failed"); q.in.share_name = r.in.share_name; status = dcerpc_srvsvc_NetShareGetInfo(p, tctx, &q); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n", - q.in.level, q.in.share_name, nt_errstr(status)); - ret = False; - continue; - } else if (!W_ERROR_EQUAL(q.out.result, WERR_OK)) { - d_printf("NetShareGetInfo level %u on share '%s' failed - %s\n", - q.in.level, q.in.share_name, win_errstr(q.out.result)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetShareGetInfo failed"); + torture_assert_werr_ok(tctx, q.out.result, "NetShareGetInfo failed"); + + torture_assert_str_equal(tctx, q.out.info.info502->name, r.in.share_name, + "share name invalid"); - if (strcmp(q.out.info.info502->name, r.in.share_name) != 0) { - ret = False; - } switch (levels[i].level) { case 0: break; case 1: - if (strcmp(q.out.info.info502->comment, "test comment 1") != 0) - ret = False; + torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 1", "comment"); break; case 2: - if (strcmp(q.out.info.info502->comment, "test comment 2") != 0) - ret = False; - if (q.out.info.info2->max_users != 2) - ret = False; - if (strcmp(q.out.info.info2->path, "C:\\") != 0) - ret = False; + torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 2", "comment"); + torture_assert_int_equal(tctx, q.out.info.info2->max_users, 2, "max users"); + torture_assert_str_equal(tctx, q.out.info.info2->path, "C:\\", "path"); break; case 501: - if (strcmp(q.out.info.info501->comment, "test comment 501") != 0) - ret = False; + torture_assert_str_equal(tctx, q.out.info.info501->comment, "test comment 501", "comment"); break; case 502: - if (strcmp(q.out.info.info502->comment, "test comment 502") != 0) - ret = False; - if (q.out.info.info2->max_users != 502) - ret = False; - if (strcmp(q.out.info.info2->path, "C:\\") != 0) - ret = False; + torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 502", "comment"); + torture_assert_int_equal(tctx, q.out.info.info2->max_users, 502, "max users"); + torture_assert_str_equal(tctx, q.out.info.info2->path, "C:\\", "path"); break; case 1004: - if (strcmp(q.out.info.info502->comment, "test comment 1004") != 0) - ret = False; + torture_assert_str_equal(tctx, q.out.info.info502->comment, "test comment 1004", + "comment"); break; case 1005: break; case 1006: - if (q.out.info.info2->max_users != 1006) - ret = False; + torture_assert_int_equal(tctx, q.out.info.info2->max_users, 1006, "Max users"); break; /* case 1007: break; @@ -728,17 +612,10 @@ static bool test_NetShareAddSetDel(struct torture_context *tctx, d.in.reserved = 0; status = dcerpc_srvsvc_NetShareDel(p, tctx, &d); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetShareDel on share 'testshare502' failed - %s\n", - nt_errstr(status)); - ret = False; - } else if (!W_ERROR_EQUAL(a.out.result, WERR_OK)) { - d_printf("NetShareDel on share 'testshare502' failed - %s\n", - win_errstr(d.out.result)); - ret = False; - } + torture_assert_ntstatus_ok(tctx, status, "NetShareDel on share 'testshare502' failed"); + torture_assert_werr_ok(tctx, a.out.result, "NetShareDel on share 'testshare502' failed"); - return ret; + return true; } /**************************/ @@ -763,7 +640,6 @@ static bool test_NetShareEnumAll(struct torture_context *tctx, { 502, WERR_ACCESS_DENIED, WERR_OK }, }; int i; - BOOL ret = True; uint32_t resume_handle; ZERO_STRUCT(c0); @@ -785,19 +661,10 @@ static bool test_NetShareEnumAll(struct torture_context *tctx, ZERO_STRUCT(r.out); resume_handle = 0; - d_printf("testing NetShareEnumAll level %u\n", r.in.level); + torture_comment(tctx, "testing NetShareEnumAll level %u\n", r.in.level); status = dcerpc_srvsvc_NetShareEnumAll(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetShareEnumAll level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } - if (!W_ERROR_EQUAL(r.out.result, expected)) { - d_printf("NetShareEnumAll level %u failed - %s (expected %s)\n", - r.in.level, win_errstr(r.out.result), - win_errstr(expected)); - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetShareEnumAll failed"); + torture_assert_werr_equal(tctx, r.out.result, expected, "NetShareEnumAll failed"); /* call srvsvc_NetShareGetInfo for each returned share */ if (r.in.level == 2 && r.out.ctr.ctr2) { @@ -805,13 +672,13 @@ static bool test_NetShareEnumAll(struct torture_context *tctx, const char *name; name = r.out.ctr.ctr2->array[j].name; if (!test_NetShareGetInfo(tctx, p, name, admin)) { - ret = False; + return false; } } } } - return ret; + return true; } static bool test_NetShareEnumAllFull(struct torture_context *tctx, @@ -844,7 +711,6 @@ static bool test_NetShareEnum(struct torture_context *tctx, { 502, WERR_ACCESS_DENIED, WERR_OK }, }; int i; - BOOL ret = True; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); r.in.ctr.ctr0 = &c0; @@ -862,22 +728,13 @@ static bool test_NetShareEnum(struct torture_context *tctx, ZERO_STRUCT(r.out); - d_printf("testing NetShareEnum level %u\n", r.in.level); + torture_comment(tctx, "testing NetShareEnum level %u\n", r.in.level); status = dcerpc_srvsvc_NetShareEnum(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetShareEnum level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } - if (!W_ERROR_EQUAL(r.out.result, expected)) { - d_printf("NetShareEnum level %u failed - %s (expected %s)\n", - r.in.level, win_errstr(r.out.result), - win_errstr(expected)); - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetShareEnum failed"); + torture_assert_werr_equal(tctx, r.out.result, expected, "NetShareEnum failed"); } - return ret; + return true; } static bool test_NetShareEnumFull(struct torture_context *tctx, @@ -896,14 +753,13 @@ static bool test_NetShareEnumAnon(struct torture_context *tctx, /* srvsvc_NetSrv */ /**************************/ static bool test_NetSrvGetInfo(struct torture_context *tctx, - struct dcerpc_pipe *p) + struct dcerpc_pipe *p) { NTSTATUS status; struct srvsvc_NetSrvGetInfo r; struct srvsvc_NetSrvInfo503 i503; uint32_t levels[] = {100, 101, 102, 502, 503}; int i; - BOOL ret = True; uint32_t resume_handle; ZERO_STRUCT(i503); @@ -914,33 +770,27 @@ static bool test_NetSrvGetInfo(struct torture_context *tctx, ZERO_STRUCT(r.out); resume_handle = 0; r.in.level = levels[i]; - d_printf("testing NetSrvGetInfo level %u\n", r.in.level); + torture_comment(tctx, "testing NetSrvGetInfo level %u\n", r.in.level); status = dcerpc_srvsvc_NetSrvGetInfo(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetSrvGetInfo failed"); if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetSrvGetInfo level %u failed - %s\n", r.in.level, win_errstr(r.out.result)); - continue; + torture_comment(tctx, "NetSrvGetInfo failed: %s\n", win_errstr(r.out.result)); } } - return ret; + return true; } /**************************/ /* srvsvc_NetDisk */ /**************************/ -static BOOL test_NetDiskEnum(struct torture_context *tctx, - struct dcerpc_pipe *p) +static bool test_NetDiskEnum(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct srvsvc_NetDiskEnum r; uint32_t levels[] = {0}; int i; - BOOL ret = True; uint32_t resume_handle=0; ZERO_STRUCT(r.in); @@ -950,37 +800,28 @@ static BOOL test_NetDiskEnum(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { ZERO_STRUCT(r.out); r.in.level = levels[i]; - d_printf("testing NetDiskEnum level %u\n", r.in.level); + torture_comment(tctx, "testing NetDiskEnum level %u\n", r.in.level); status = dcerpc_srvsvc_NetDiskEnum(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - NDR_PRINT_OUT_DEBUG(srvsvc_NetDiskEnum, &r); - d_printf("NetDiskEnum level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } - if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetDiskEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result)); - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetDiskEnum failed"); + torture_assert_werr_ok(tctx, r.out.result, "NetDiskEnum failed"); } - return ret; + return true; } /**************************/ /* srvsvc_NetTransport */ /**************************/ static bool test_NetTransportEnum(struct torture_context *tctx, - struct dcerpc_pipe *p) + struct dcerpc_pipe *p) { NTSTATUS status; struct srvsvc_NetTransportEnum r; struct srvsvc_NetTransportCtr0 c0; uint32_t levels[] = {0, 1}; int i; - BOOL ret = True; - r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); + r.in.server_unc = talloc_asprintf(tctx,"\\\\%s", dcerpc_server_name(p)); r.in.transports.ctr0 = &c0; r.in.transports.ctr0->count = 0; r.in.transports.ctr0->array = NULL; @@ -990,46 +831,35 @@ static bool test_NetTransportEnum(struct torture_context *tctx, for (i=0;i<ARRAY_SIZE(levels);i++) { ZERO_STRUCT(r.out); r.in.level = levels[i]; - d_printf("testing NetTransportEnum level %u\n", r.in.level); + torture_comment(tctx, "testing NetTransportEnum level %u\n", r.in.level); status = dcerpc_srvsvc_NetTransportEnum(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetTransportEnum level %u failed - %s\n", r.in.level, nt_errstr(status)); - ret = False; - continue; - } + torture_assert_ntstatus_ok(tctx, status, "NetTransportEnum failed"); if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetTransportEnum level %u failed - %s\n", r.in.level, win_errstr(r.out.result)); - continue; + torture_comment(tctx, "unexpected result: %s\n", win_errstr(r.out.result)); } } - return ret; + return true; } /**************************/ /* srvsvc_NetRemoteTOD */ /**************************/ -static BOOL test_NetRemoteTOD(struct torture_context *tctx, - struct dcerpc_pipe *p) +static bool test_NetRemoteTOD(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct srvsvc_NetRemoteTOD r; - BOOL ret = True; r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p)); ZERO_STRUCT(r.out); - d_printf("testing NetRemoteTOD\n"); + torture_comment(tctx, "testing NetRemoteTOD\n"); status = dcerpc_srvsvc_NetRemoteTOD(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - d_printf("NetRemoteTOD failed - %s\n", nt_errstr(status)); - ret = False; - } - if (!W_ERROR_IS_OK(r.out.result)) { - d_printf("NetRemoteTOD failed - %s\n", win_errstr(r.out.result)); - } + torture_assert_ntstatus_ok(tctx, status, "NetRemoteTOD failed"); + torture_assert_werr_ok(tctx, r.out.result, "NetRemoteTOD failed"); - return ret; + return true; } /**************************/ @@ -1108,7 +938,7 @@ again: } if (!W_ERROR_IS_OK(r.out.result)) { - invalidc = talloc_asprintf_append(invalidc, "%c", (char)n); + invalidc = talloc_asprintf_append_buffer(invalidc, "%c", (char)n); } talloc_free(name); @@ -1125,13 +955,14 @@ again: r.in.flags = 0x0; } - return True; + return true; } struct torture_suite *torture_rpc_srvsvc(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, "SRVSVC"); struct torture_rpc_tcase *tcase; + struct torture_test *test; tcase = torture_suite_add_rpc_iface_tcase(suite, "srvsvc (admin access)", &ndr_table_srvsvc); @@ -1147,8 +978,9 @@ struct torture_suite *torture_rpc_srvsvc(TALLOC_CTX *mem_ctx) torture_rpc_tcase_add_test(tcase, "NetRemoteTOD", test_NetRemoteTOD); torture_rpc_tcase_add_test(tcase, "NetShareEnum", test_NetShareEnumFull); torture_rpc_tcase_add_test(tcase, "NetShareGetInfo", test_NetShareGetInfoAdminFull); - torture_rpc_tcase_add_test(tcase, "NetShareAddSetDel", - test_NetShareAddSetDel); + test = torture_rpc_tcase_add_test(tcase, "NetShareAddSetDel", + test_NetShareAddSetDel); + test->dangerous = true; torture_rpc_tcase_add_test(tcase, "NetNameValidate", test_NetNameValidate); tcase = torture_suite_add_anon_rpc_iface_tcase(suite, diff --git a/source4/torture/rpc/svcctl.c b/source4/torture/rpc/svcctl.c index 2f2b4ec485..c9006baaf5 100644 --- a/source4/torture/rpc/svcctl.c +++ b/source4/torture/rpc/svcctl.c @@ -80,7 +80,7 @@ static bool test_EnumServicesStatus(struct torture_context *tctx, struct dcerpc_ if (W_ERROR_EQUAL(r.out.result, WERR_MORE_DATA)) { r.in.buf_size = *r.out.bytes_needed; - r.out.service = talloc_size(tctx, *r.out.bytes_needed); + r.out.service = talloc_array(tctx, uint8_t, *r.out.bytes_needed); status = dcerpc_svcctl_EnumServicesStatusW(p, tctx, &r); diff --git a/source4/torture/rpc/testjoin.c b/source4/torture/rpc/testjoin.c index 56a0fccde4..725799f2dd 100644 --- a/source4/torture/rpc/testjoin.c +++ b/source4/torture/rpc/testjoin.c @@ -36,6 +36,7 @@ #include "libcli/auth/libcli_auth.h" #include "torture/rpc/rpc.h" #include "libcli/security/security.h" +#include "param/param.h" struct test_join { struct dcerpc_pipe *p; @@ -125,7 +126,7 @@ struct test_join *torture_create_testuser(struct torture_context *torture, int policy_min_pw_len = 0; struct test_join *join; char *random_pw; - const char *dc_binding = lp_parm_string(-1, "torture", "dc_binding"); + const char *dc_binding = lp_parm_string(global_loadparm, NULL, "torture", "dc_binding"); join = talloc(NULL, struct test_join); if (join == NULL) { @@ -275,7 +276,8 @@ again: u.info21.description.string = talloc_asprintf(join, "Samba4 torture account created by host %s: %s", - lp_netbios_name(), timestring(join, time(NULL))); + lp_netbios_name(global_loadparm), + timestring(join, time(NULL))); printf("Resetting ACB flags, force pw change time\n"); @@ -326,9 +328,9 @@ _PUBLIC_ struct test_join *torture_join_domain(const char *machine_name, tj->libnet_r = libnet_r; libnet_ctx->cred = cmdline_credentials; - libnet_r->in.binding = lp_parm_string(-1, "torture", "binding"); + libnet_r->in.binding = lp_parm_string(global_loadparm, NULL, "torture", "binding"); if (!libnet_r->in.binding) { - libnet_r->in.binding = talloc_asprintf(libnet_r, "ncacn_np:%s", lp_parm_string(-1, "torture", "host")); + libnet_r->in.binding = talloc_asprintf(libnet_r, "ncacn_np:%s", lp_parm_string(global_loadparm, NULL, "torture", "host")); } libnet_r->in.level = LIBNET_JOINDOMAIN_SPECIFIED; libnet_r->in.netbios_name = machine_name; @@ -339,7 +341,7 @@ _PUBLIC_ struct test_join *torture_join_domain(const char *machine_name, } libnet_r->in.acct_type = acct_flags; - libnet_r->in.recreate_account = True; + libnet_r->in.recreate_account = true; status = libnet_JoinDomain(libnet_ctx, libnet_r, libnet_r); if (!NT_STATUS_IS_OK(status)) { @@ -381,7 +383,7 @@ _PUBLIC_ struct test_join *torture_join_domain(const char *machine_name, u.info21.description.string = talloc_asprintf(tj, "Samba4 torture account created by host %s: %s", - lp_netbios_name(), timestring(tj, time(NULL))); + lp_netbios_name(global_loadparm), timestring(tj, time(NULL))); status = dcerpc_samr_SetUserInfo(tj->p, tj, &s); if (!NT_STATUS_IS_OK(status)) { @@ -389,7 +391,7 @@ _PUBLIC_ struct test_join *torture_join_domain(const char *machine_name, } *machine_credentials = cli_credentials_init(tj); - cli_credentials_set_conf(*machine_credentials); + cli_credentials_set_conf(*machine_credentials, global_loadparm); cli_credentials_set_workstation(*machine_credentials, machine_name, CRED_SPECIFIED); cli_credentials_set_domain(*machine_credentials, libnet_r->out.domain_name, CRED_SPECIFIED); if (libnet_r->out.realm) { diff --git a/source4/torture/rpc/unixinfo.c b/source4/torture/rpc/unixinfo.c index 80d7d96a9e..cbe8cf0ff1 100644 --- a/source4/torture/rpc/unixinfo.c +++ b/source4/torture/rpc/unixinfo.c @@ -42,7 +42,7 @@ static bool test_sidtouid(struct torture_context *tctx, struct dcerpc_pipe *p) if (NT_STATUS_EQUAL(NT_STATUS_NONE_MAPPED, status)) { } else torture_assert_ntstatus_ok(tctx, status, "SidToUid failed"); - return True; + return true; } /* @@ -125,12 +125,12 @@ static bool test_gidtosid(struct torture_context *tctx, struct dcerpc_pipe *p) return true; } -struct torture_suite *torture_rpc_unixinfo(void) +struct torture_suite *torture_rpc_unixinfo(TALLOC_CTX *mem_ctx) { struct torture_suite *suite; struct torture_rpc_tcase *tcase; - suite = torture_suite_create(talloc_autofree_context(), "UNIXINFO"); + suite = torture_suite_create(mem_ctx, "UNIXINFO"); tcase = torture_suite_add_rpc_iface_tcase(suite, "unixinfo", &ndr_table_unixinfo); diff --git a/source4/torture/rpc/winreg.c b/source4/torture/rpc/winreg.c index a3d671c489..e29d0b74dd 100644 --- a/source4/torture/rpc/winreg.c +++ b/source4/torture/rpc/winreg.c @@ -1,20 +1,20 @@ -/* +/* Unix SMB/CIFS implementation. test suite for winreg rpc operations Copyright (C) Tim Potter 2003 Copyright (C) Jelmer Vernooij 2004-2007 - + 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/>. */ @@ -32,9 +32,9 @@ #define TEST_KEY3 TEST_KEY_BASE "\\with a subkey" #define TEST_SUBKEY TEST_KEY3 "\\subkey" -static void init_initshutdown_String(TALLOC_CTX *mem_ctx, - struct initshutdown_String *name, - const char *s) +static void init_initshutdown_String(TALLOC_CTX *mem_ctx, + struct initshutdown_String *name, + const char *s) { name->name = talloc(mem_ctx, struct initshutdown_String_sub); name->name->name = s; @@ -52,8 +52,8 @@ static void init_winreg_String(struct winreg_String *name, const char *s) } } -static bool test_GetVersion(struct dcerpc_pipe *p, - struct torture_context *tctx, +static bool test_GetVersion(struct dcerpc_pipe *p, + struct torture_context *tctx, struct policy_handle *handle) { struct winreg_GetVersion r; @@ -64,16 +64,16 @@ static bool test_GetVersion(struct dcerpc_pipe *p, r.out.version = &v; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_GetVersion(p, tctx, &r), - "GetVersion failed"); + "GetVersion failed"); torture_assert_werr_ok(tctx, r.out.result, "GetVersion failed"); return true; } -static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p, - struct torture_context *tctx, - struct policy_handle *handle) +static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct policy_handle *handle) { struct winreg_NotifyChangeKeyValue r; @@ -84,13 +84,13 @@ static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p, init_winreg_String(&r.in.string1, NULL); init_winreg_String(&r.in.string2, NULL); - torture_assert_ntstatus_ok(tctx, - dcerpc_winreg_NotifyChangeKeyValue(p, tctx, &r), - "NotifyChangeKeyValue failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_winreg_NotifyChangeKeyValue(p, tctx, &r), + "NotifyChangeKeyValue failed"); if (!W_ERROR_IS_OK(r.out.result)) { - torture_comment(tctx, - "NotifyChangeKeyValue failed - %s - not considering\n", win_errstr(r.out.result)); + torture_comment(tctx, + "NotifyChangeKeyValue failed - %s - not considering\n", win_errstr(r.out.result)); return true; } @@ -98,7 +98,7 @@ static bool test_NotifyChangeKeyValue(struct dcerpc_pipe *p, } static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, - struct policy_handle *handle, const char *name, + struct policy_handle *handle, const char *name, const char *class) { struct winreg_CreateKey r; @@ -107,7 +107,7 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, r.in.handle = handle; r.out.new_handle = &newhandle; - init_winreg_String(&r.in.name, name); + init_winreg_String(&r.in.name, name); init_winreg_String(&r.in.keyclass, class); r.in.options = 0x0; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -115,7 +115,7 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, r.in.secdesc = NULL; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_CreateKey(p, tctx, &r), - "CreateKey failed"); + "CreateKey failed"); torture_assert_werr_ok(tctx, r.out.result, "CreateKey failed"); @@ -126,9 +126,9 @@ static bool test_CreateKey(struct dcerpc_pipe *p, struct torture_context *tctx, /* createkey testing with a SD */ -static bool test_CreateKey_sd(struct dcerpc_pipe *p, - struct torture_context *tctx, - struct policy_handle *handle, const char *name, +static bool test_CreateKey_sd(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct policy_handle *handle, const char *name, const char *class, struct policy_handle *newhandle) { struct winreg_CreateKey r; @@ -145,10 +145,10 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p, SEC_ACE_FLAG_OBJECT_INHERIT, NULL); - torture_assert_ntstatus_ok(tctx, - ndr_push_struct_blob(&sdblob, tctx, sd, - (ndr_push_flags_fn_t)ndr_push_security_descriptor), - "Failed to push security_descriptor ?!\n"); + torture_assert_ntstatus_ok(tctx, + ndr_push_struct_blob(&sdblob, tctx, sd, + (ndr_push_flags_fn_t)ndr_push_security_descriptor), + "Failed to push security_descriptor ?!\n"); secbuf.sd.data = sdblob.data; secbuf.sd.len = sdblob.length; @@ -158,7 +158,7 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p, r.in.handle = handle; r.out.new_handle = newhandle; - init_winreg_String(&r.in.name, name); + init_winreg_String(&r.in.name, name); init_winreg_String(&r.in.keyclass, class); r.in.options = 0x0; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; @@ -166,16 +166,16 @@ static bool test_CreateKey_sd(struct dcerpc_pipe *p, r.in.secdesc = &secbuf; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_CreateKey(p, tctx, &r), - "CreateKey with sd failed"); + "CreateKey with sd failed"); torture_assert_werr_ok(tctx, r.out.result, "CreateKey with sd failed"); return true; } -static bool test_GetKeySecurity(struct dcerpc_pipe *p, - struct torture_context *tctx, - struct policy_handle *handle) +static bool test_GetKeySecurity(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct policy_handle *handle) { struct winreg_GetKeySecurity r; struct security_descriptor sd; @@ -189,17 +189,17 @@ static bool test_GetKeySecurity(struct dcerpc_pipe *p, r.in.sec_info = SECINFO_OWNER | SECINFO_GROUP | SECINFO_DACL; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_GetKeySecurity(p, tctx, &r), - "GetKeySecurity failed"); + "GetKeySecurity failed"); torture_assert_werr_ok(tctx, r.out.result, "GetKeySecurity failed"); sdblob.data = r.out.sd->data; sdblob.length = r.out.sd->len; - torture_assert_ntstatus_ok(tctx, - ndr_pull_struct_blob(&sdblob, tctx, &sd, - (ndr_pull_flags_fn_t)ndr_pull_security_descriptor), - "pull_security_descriptor failed"); + torture_assert_ntstatus_ok(tctx, + ndr_pull_struct_blob(&sdblob, tctx, &sd, + (ndr_pull_flags_fn_t)ndr_pull_security_descriptor), + "pull_security_descriptor failed"); if (p->conn->flags & DCERPC_DEBUG_PRINT_OUT) { NDR_PRINT_DEBUG(security_descriptor, &sd); @@ -208,7 +208,7 @@ static bool test_GetKeySecurity(struct dcerpc_pipe *p, return true; } -static bool test_CloseKey(struct dcerpc_pipe *p, struct torture_context *tctx, +static bool test_CloseKey(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *handle) { struct winreg_CloseKey r; @@ -216,14 +216,14 @@ static bool test_CloseKey(struct dcerpc_pipe *p, struct torture_context *tctx, r.in.handle = r.out.handle = handle; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_CloseKey(p, tctx, &r), - "CloseKey failed"); + "CloseKey failed"); torture_assert_werr_ok(tctx, r.out.result, "CloseKey failed"); return true; } -static bool test_FlushKey(struct dcerpc_pipe *p, struct torture_context *tctx, +static bool test_FlushKey(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *handle) { struct winreg_FlushKey r; @@ -231,7 +231,7 @@ static bool test_FlushKey(struct dcerpc_pipe *p, struct torture_context *tctx, r.in.handle = handle; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_FlushKey(p, tctx, &r), - "FlushKey failed"); + "FlushKey failed"); torture_assert_werr_ok(tctx, r.out.result, "FlushKey failed"); @@ -251,7 +251,7 @@ static bool test_OpenKey(struct dcerpc_pipe *p, struct torture_context *tctx, r.out.handle = key_handle; torture_assert_ntstatus_ok(tctx, dcerpc_winreg_OpenKey(p, tctx, &r), - "OpenKey failed"); + "OpenKey failed"); torture_assert_werr_ok(tctx, r.out.result, "OpenKey failed"); @@ -279,7 +279,7 @@ static bool test_DeleteKey(struct dcerpc_pipe *p, struct torture_context *tctx, struct winreg_DeleteKey r; r.in.handle = handle; - init_winreg_String(&r.in.key, key); + init_winreg_String(&r.in.key, key); status = dcerpc_winreg_DeleteKey(p, tctx, &r); @@ -291,7 +291,7 @@ static bool test_DeleteKey(struct dcerpc_pipe *p, struct torture_context *tctx, /* DeleteKey on a key with subkey(s) should * return WERR_ACCESS_DENIED. */ -static bool test_DeleteKeyWithSubkey(struct dcerpc_pipe *p, +static bool test_DeleteKeyWithSubkey(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *handle, const char *key) { @@ -301,16 +301,16 @@ static bool test_DeleteKeyWithSubkey(struct dcerpc_pipe *p, init_winreg_String(&r.in.key, key); torture_assert_ntstatus_ok(tctx, dcerpc_winreg_DeleteKey(p, tctx, &r), - "DeleteKeyWithSubkey failed"); + "DeleteKeyWithSubkey failed"); - torture_assert_werr_equal(tctx, r.out.result, WERR_ACCESS_DENIED, - "DeleteKeyWithSubkey failed"); + torture_assert_werr_equal(tctx, r.out.result, WERR_ACCESS_DENIED, + "DeleteKeyWithSubkey failed"); return true; } -static bool test_QueryInfoKey(struct dcerpc_pipe *p, - struct torture_context *tctx, +static bool test_QueryInfoKey(struct dcerpc_pipe *p, + struct torture_context *tctx, struct policy_handle *handle, char *class) { struct winreg_QueryInfoKey r; @@ -331,13 +331,13 @@ static bool test_QueryInfoKey(struct dcerpc_pipe *p, r.out.last_changed_time = &last_changed_time; r.out.classname = talloc(tctx, struct winreg_String); - + r.in.classname = talloc(tctx, struct winreg_String); init_winreg_String(r.in.classname, class); - - torture_assert_ntstatus_ok(tctx, - dcerpc_winreg_QueryInfoKey(p, tctx, &r), - "QueryInfoKey failed"); + + torture_assert_ntstatus_ok(tctx, + dcerpc_winreg_QueryInfoKey(p, tctx, &r), + "QueryInfoKey failed"); torture_assert_werr_ok(tctx, r.out.result, "QueryInfoKey failed"); @@ -375,11 +375,10 @@ static bool test_EnumKey(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle key_handle; torture_comment(tctx, "EnumKey: %d: %s\n", r.in.enum_index, - r.out.name->name); + r.out.name->name); - if (!test_OpenKey( - p, tctx, handle, r.out.name->name, - &key_handle)) { + if (!test_OpenKey(p, tctx, handle, r.out.name->name, + &key_handle)) { } else { test_key(p, tctx, &key_handle, depth + 1); } @@ -391,7 +390,7 @@ static bool test_EnumKey(struct dcerpc_pipe *p, struct torture_context *tctx, torture_assert_ntstatus_ok(tctx, status, "EnumKey failed"); - if (!W_ERROR_IS_OK(r.out.result) && + if (!W_ERROR_IS_OK(r.out.result) && !W_ERROR_EQUAL(r.out.result, WERR_NO_MORE_ITEMS)) { torture_fail(tctx, "EnumKey failed"); } @@ -399,10 +398,10 @@ static bool test_EnumKey(struct dcerpc_pipe *p, struct torture_context *tctx, return true; } -static bool test_QueryMultipleValues(struct dcerpc_pipe *p, - struct torture_context *tctx, - struct policy_handle *handle, - const char *valuename) +static bool test_QueryMultipleValues(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct policy_handle *handle, + const char *valuename) { struct winreg_QueryMultipleValues r; NTSTATUS status; @@ -419,13 +418,13 @@ static bool test_QueryMultipleValues(struct dcerpc_pipe *p, r.in.num_values = 1; r.in.buffer_size = r.out.buffer_size = talloc(tctx, uint32_t); *r.in.buffer_size = bufsize; - do { + do { *r.in.buffer_size = bufsize; - r.in.buffer = r.out.buffer = talloc_zero_array(tctx, uint8_t, + r.in.buffer = r.out.buffer = talloc_zero_array(tctx, uint8_t, *r.in.buffer_size); status = dcerpc_winreg_QueryMultipleValues(p, tctx, &r); - + if(NT_STATUS_IS_ERR(status)) torture_fail(tctx, "QueryMultipleValues failed"); @@ -438,10 +437,10 @@ static bool test_QueryMultipleValues(struct dcerpc_pipe *p, return true; } -static bool test_QueryValue(struct dcerpc_pipe *p, - struct torture_context *tctx, - struct policy_handle *handle, - const char *valuename) +static bool test_QueryValue(struct dcerpc_pipe *p, + struct torture_context *tctx, + struct policy_handle *handle, + const char *valuename) { struct winreg_QueryValue r; NTSTATUS status; @@ -467,7 +466,8 @@ static bool test_QueryValue(struct dcerpc_pipe *p, } static bool test_EnumValue(struct dcerpc_pipe *p, struct torture_context *tctx, - struct policy_handle *handle, int max_valnamelen, int max_valbufsize) + struct policy_handle *handle, int max_valnamelen, + int max_valbufsize) { struct winreg_EnumValue r; enum winreg_Type type = 0; @@ -487,10 +487,11 @@ static bool test_EnumValue(struct dcerpc_pipe *p, struct torture_context *tctx, r.in.value = &buf8; r.in.length = &zero; r.in.size = &size; - + do { - torture_assert_ntstatus_ok(tctx, dcerpc_winreg_EnumValue(p, tctx, &r), - "EnumValue failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_winreg_EnumValue(p, tctx, &r), + "EnumValue failed"); if (W_ERROR_IS_OK(r.out.result)) { ret &= test_QueryValue(p, tctx, handle, r.out.name->name); @@ -501,22 +502,22 @@ static bool test_EnumValue(struct dcerpc_pipe *p, struct torture_context *tctx, } while (W_ERROR_IS_OK(r.out.result)); torture_assert_werr_equal(tctx, r.out.result, WERR_NO_MORE_ITEMS, - "EnumValue failed"); + "EnumValue failed"); return ret; } -static bool test_AbortSystemShutdown(struct dcerpc_pipe *p, - struct torture_context *tctx) +static bool test_AbortSystemShutdown(struct dcerpc_pipe *p, + struct torture_context *tctx) { struct winreg_AbortSystemShutdown r; uint16_t server = 0x0; r.in.server = &server; - - torture_assert_ntstatus_ok(tctx, - dcerpc_winreg_AbortSystemShutdown(p, tctx, &r), - "AbortSystemShutdown failed"); + + torture_assert_ntstatus_ok(tctx, + dcerpc_winreg_AbortSystemShutdown(p, tctx, &r), + "AbortSystemShutdown failed"); torture_assert_werr_ok(tctx, r.out.result, "AbortSystemShutdown failed"); @@ -524,15 +525,11 @@ static bool test_AbortSystemShutdown(struct dcerpc_pipe *p, } static bool test_InitiateSystemShutdown(struct torture_context *tctx, - struct dcerpc_pipe *p) + struct dcerpc_pipe *p) { struct winreg_InitiateSystemShutdown r; uint16_t hostname = 0x0; - if (!torture_setting_bool(tctx, "dangerous", false)) - torture_skip(tctx, - "winreg_InitiateShutdown disabled - enable dangerous tests to use"); - r.in.hostname = &hostname; r.in.message = talloc(tctx, struct initshutdown_String); init_initshutdown_String(tctx, r.in.message, "spottyfood"); @@ -540,9 +537,9 @@ static bool test_InitiateSystemShutdown(struct torture_context *tctx, r.in.timeout = 30; r.in.reboot = 1; - torture_assert_ntstatus_ok(tctx, - dcerpc_winreg_InitiateSystemShutdown(p, tctx, &r), - "InitiateSystemShutdown failed"); + torture_assert_ntstatus_ok(tctx, + dcerpc_winreg_InitiateSystemShutdown(p, tctx, &r), + "InitiateSystemShutdown failed"); torture_assert_werr_ok(tctx, r.out.result, "InitiateSystemShutdown failed"); @@ -551,15 +548,11 @@ static bool test_InitiateSystemShutdown(struct torture_context *tctx, static bool test_InitiateSystemShutdownEx(struct torture_context *tctx, - struct dcerpc_pipe *p) + struct dcerpc_pipe *p) { struct winreg_InitiateSystemShutdownEx r; uint16_t hostname = 0x0; - if (!torture_setting_bool(tctx, "dangerous", false)) - torture_skip(tctx, - "winreg_InitiateShutdownEx disabled - enable dangerous tests to use"); - r.in.hostname = &hostname; r.in.message = talloc(tctx, struct initshutdown_String); init_initshutdown_String(tctx, r.in.message, "spottyfood"); @@ -568,18 +561,18 @@ static bool test_InitiateSystemShutdownEx(struct torture_context *tctx, r.in.reboot = 1; r.in.reason = 0; - torture_assert_ntstatus_ok(tctx, + torture_assert_ntstatus_ok(tctx, dcerpc_winreg_InitiateSystemShutdownEx(p, tctx, &r), "InitiateSystemShutdownEx failed"); - torture_assert_werr_ok(tctx, r.out.result, - "InitiateSystemShutdownEx failed"); + torture_assert_werr_ok(tctx, r.out.result, + "InitiateSystemShutdownEx failed"); return test_AbortSystemShutdown(p, tctx); } #define MAX_DEPTH 2 /* Only go this far down the tree */ -static bool test_key(struct dcerpc_pipe *p, struct torture_context *tctx, +static bool test_key(struct dcerpc_pipe *p, struct torture_context *tctx, struct policy_handle *handle, int depth) { if (depth == MAX_DEPTH) @@ -590,7 +583,7 @@ static bool test_key(struct dcerpc_pipe *p, struct torture_context *tctx, if (!test_NotifyChangeKeyValue(p, tctx, handle)) { } - + if (!test_GetKeySecurity(p, tctx, handle)) { } @@ -607,7 +600,7 @@ static bool test_key(struct dcerpc_pipe *p, struct torture_context *tctx, typedef NTSTATUS (*winreg_open_fn)(struct dcerpc_pipe *, TALLOC_CTX *, void *); -static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p, +static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p, void *userdata) { struct policy_handle handle, newhandle; @@ -620,9 +613,9 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p, r.in.system_name = 0; r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; r.out.handle = &handle; - - torture_assert_ntstatus_ok(tctx, open_fn(p, tctx, &r), - "open"); + + torture_assert_ntstatus_ok(tctx, open_fn(p, tctx, &r), + "open"); test_Cleanup(p, tctx, &handle, TEST_KEY1); test_Cleanup(p, tctx, &handle, TEST_KEY2); @@ -642,8 +635,8 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p, } if (created && !test_OpenKey(p, tctx, &handle, TEST_KEY1, &newhandle)) - torture_fail(tctx, - "CreateKey failed (OpenKey after Create didn't work)\n"); + torture_fail(tctx, + "CreateKey failed (OpenKey after Create didn't work)\n"); if (created && !test_DeleteKey(p, tctx, &handle, TEST_KEY1)) { torture_comment(tctx, "DeleteKey failed\n"); @@ -657,10 +650,10 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p, ret = false; } - if (created && deleted && + if (created && deleted && test_OpenKey(p, tctx, &handle, TEST_KEY1, &newhandle)) { - torture_comment(tctx, - "DeleteKey failed (OpenKey after Delete worked)\n"); + torture_comment(tctx, + "DeleteKey failed (OpenKey after Delete worked)\n"); ret = false; } @@ -669,8 +662,8 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p, ret = false; } - if (created && test_CreateKey_sd(p, tctx, &handle, TEST_KEY2, - NULL, &newhandle)) { + if (created && test_CreateKey_sd(p, tctx, &handle, TEST_KEY2, + NULL, &newhandle)) { created2 = true; } @@ -693,21 +686,21 @@ static bool test_Open(struct torture_context *tctx, struct dcerpc_pipe *p, created3 = true; } - if (created3 && - test_CreateKey(p, tctx, &handle, TEST_SUBKEY, NULL)) + if (created3 && + test_CreateKey(p, tctx, &handle, TEST_SUBKEY, NULL)) { created_subkey = true; } - if (created_subkey && - !test_DeleteKeyWithSubkey(p, tctx, &handle, TEST_KEY3)) + if (created_subkey && + !test_DeleteKeyWithSubkey(p, tctx, &handle, TEST_KEY3)) { printf("DeleteKeyWithSubkey failed " "(DeleteKey didn't return ACCESS_DENIED)\n"); ret = false; } - if (created_subkey && + if (created_subkey && !test_DeleteKey(p, tctx, &handle, TEST_SUBKEY)) { printf("DeleteKey failed\n"); @@ -749,19 +742,22 @@ struct torture_suite *torture_rpc_winreg(TALLOC_CTX *mem_ctx) int i; struct torture_rpc_tcase *tcase; struct torture_suite *suite = torture_suite_create(mem_ctx, "WINREG"); + struct torture_test *test; - tcase = torture_suite_add_rpc_iface_tcase(suite, "winreg", - &ndr_table_winreg); + tcase = torture_suite_add_rpc_iface_tcase(suite, "winreg", + &ndr_table_winreg); - torture_rpc_tcase_add_test(tcase, "InitiateSystemShutdown", - test_InitiateSystemShutdown); + test = torture_rpc_tcase_add_test(tcase, "InitiateSystemShutdown", + test_InitiateSystemShutdown); + test->dangerous = true; - torture_rpc_tcase_add_test(tcase, "InitiateSystemShutdownEx", - test_InitiateSystemShutdownEx); + test = torture_rpc_tcase_add_test(tcase, "InitiateSystemShutdownEx", + test_InitiateSystemShutdownEx); + test->dangerous = true; for (i = 0; i < ARRAY_SIZE(open_fns); i++) { - torture_rpc_tcase_add_test_ex(tcase, open_fns[i].name, test_Open, - open_fns[i].fn); + torture_rpc_tcase_add_test_ex(tcase, open_fns[i].name, + test_Open, open_fns[i].fn); } return suite; diff --git a/source4/torture/smb2/connect.c b/source4/torture/smb2/connect.c index 62d273e623..796b180ddf 100644 --- a/source4/torture/smb2/connect.c +++ b/source4/torture/smb2/connect.c @@ -25,6 +25,7 @@ #include "libcli/smb2/smb2_calls.h" #include "torture/torture.h" #include "torture/smb2/proto.h" +#include "param/param.h" /* send a close @@ -73,9 +74,9 @@ static NTSTATUS torture_smb2_write(struct smb2_tree *tree, struct smb2_handle ha DATA_BLOB data; int i; - if (lp_parm_bool(-1, "torture", "dangerous", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "dangerous", false)) { data = data_blob_talloc(tree, NULL, 160000); - } else if (lp_parm_bool(-1, "torture", "samba4", False)) { + } else if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { data = data_blob_talloc(tree, NULL, UINT16_MAX); } else { data = data_blob_talloc(tree, NULL, 120000); @@ -188,7 +189,7 @@ static struct smb2_handle torture_smb2_create(struct smb2_tree *tree, /* basic testing of SMB2 connection calls */ -BOOL torture_smb2_connect(struct torture_context *torture) +bool torture_smb2_connect(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; @@ -196,7 +197,7 @@ BOOL torture_smb2_connect(struct torture_context *torture) NTSTATUS status; if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } h1 = torture_smb2_create(tree, "test9.dat"); @@ -204,56 +205,56 @@ BOOL torture_smb2_connect(struct torture_context *torture) status = torture_smb2_write(tree, h1); if (!NT_STATUS_IS_OK(status)) { printf("Write failed - %s\n", nt_errstr(status)); - return False; + return false; } status = torture_smb2_close(tree, h1); if (!NT_STATUS_IS_OK(status)) { printf("Close failed - %s\n", nt_errstr(status)); - return False; + return false; } status = torture_smb2_close(tree, h2); if (!NT_STATUS_IS_OK(status)) { printf("Close failed - %s\n", nt_errstr(status)); - return False; + return false; } status = smb2_util_close(tree, h1); if (!NT_STATUS_EQUAL(status, NT_STATUS_FILE_CLOSED)) { printf("close should have closed the handle - %s\n", nt_errstr(status)); - return False; + return false; } status = smb2_tdis(tree); if (!NT_STATUS_IS_OK(status)) { printf("tdis failed - %s\n", nt_errstr(status)); - return False; + return false; } status = smb2_tdis(tree); if (!NT_STATUS_EQUAL(status, NT_STATUS_NETWORK_NAME_DELETED)) { printf("tdis should have disabled session - %s\n", nt_errstr(status)); - return False; + return false; } status = smb2_logoff(tree->session); if (!NT_STATUS_IS_OK(status)) { printf("Logoff failed - %s\n", nt_errstr(status)); - return False; + return false; } status = smb2_logoff(tree->session); if (!NT_STATUS_EQUAL(status, NT_STATUS_USER_SESSION_DELETED)) { printf("Logoff should have disabled session - %s\n", nt_errstr(status)); - return False; + return false; } status = smb2_keepalive(tree->session->transport); if (!NT_STATUS_IS_OK(status)) { printf("keepalive failed? - %s\n", nt_errstr(status)); - return False; + return false; } talloc_free(mem_ctx); - return True; + return true; } diff --git a/source4/torture/smb2/dir.c b/source4/torture/smb2/dir.c index 428683522a..eb24dd0884 100644 --- a/source4/torture/smb2/dir.c +++ b/source4/torture/smb2/dir.c @@ -29,19 +29,19 @@ /* test find continue */ -static BOOL torture_smb2_find_dir(struct smb2_tree *tree) +static bool torture_smb2_find_dir(struct smb2_tree *tree) { struct smb2_handle handle; NTSTATUS status; int i; struct smb2_find f; - BOOL ret = True; + bool ret = true; union smb_search_data *d; uint_t count; status = smb2_util_roothandle(tree, &handle); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } ZERO_STRUCT(f); @@ -75,14 +75,14 @@ static BOOL torture_smb2_find_dir(struct smb2_tree *tree) /* basic testing of directory listing with continue */ -BOOL torture_smb2_dir(struct torture_context *torture) +bool torture_smb2_dir(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; - BOOL ret = True; + bool ret = true; if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } ret &= torture_smb2_find_dir(tree); diff --git a/source4/torture/smb2/find.c b/source4/torture/smb2/find.c index 2b4bde7865..654866dfb5 100644 --- a/source4/torture/smb2/find.c +++ b/source4/torture/smb2/find.c @@ -49,7 +49,7 @@ static struct { printf("(%s) %s/%s should be 0x%llx - 0x%llx\n", __location__, \ #call_name, #field, \ (long long)io.all_info2.out.field, (long long)d->stype.field); \ - ret = False; \ + ret = false; \ }} while (0) #define CHECK_CONST_STRING(call_name, stype, field, str) do { \ @@ -58,7 +58,7 @@ static struct { printf("(%s) %s/%s should be '%s' - '%s'\n", __location__, \ #call_name, #field, \ str, d->stype.field.s); \ - ret = False; \ + ret = false; \ }} while (0) static union smb_search_data *find_level(const char *name) @@ -75,26 +75,26 @@ static union smb_search_data *find_level(const char *name) /* test find levels */ -static BOOL torture_smb2_find_levels(struct smb2_tree *tree) +static bool torture_smb2_find_levels(struct smb2_tree *tree) { struct smb2_handle handle; NTSTATUS status; int i; struct smb2_find f; - BOOL ret = True; + bool ret = true; union smb_fileinfo io; const char *alt_name; status = smb2_create_complex_file(tree, FNAME, &handle); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } io.generic.level = RAW_FILEINFO_ALT_NAME_INFORMATION; io.generic.in.file.handle = handle; status = smb2_getinfo_file(tree, tree, &io); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } alt_name = talloc_strdup(tree, io.alt_name_info.out.fname.s); @@ -102,12 +102,12 @@ static BOOL torture_smb2_find_levels(struct smb2_tree *tree) io.generic.in.file.handle = handle; status = smb2_getinfo_file(tree, tree, &io); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } status = smb2_util_roothandle(tree, &handle); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } ZERO_STRUCT(f); @@ -130,7 +130,7 @@ static BOOL torture_smb2_find_levels(struct smb2_tree *tree) if (count != 1) { printf("Expected count 1 - got %d in %s\n", count, levels[i].name); - ret = False; + ret = false; } levels[i].data = d[0]; @@ -195,20 +195,20 @@ static BOOL torture_smb2_find_levels(struct smb2_tree *tree) /* basic testing of all SMB2 find levels */ -BOOL torture_smb2_find(struct torture_context *torture) +bool torture_smb2_find(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; - BOOL ret = True; + bool ret = true; NTSTATUS status; if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } status = torture_setup_complex_file(tree, FNAME); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } torture_setup_complex_file(tree, FNAME ":streamtwo"); diff --git a/source4/torture/smb2/getinfo.c b/source4/torture/smb2/getinfo.c index fc59d1ac30..9ed0b9ddb5 100644 --- a/source4/torture/smb2/getinfo.c +++ b/source4/torture/smb2/getinfo.c @@ -26,6 +26,8 @@ #include "torture/torture.h" #include "torture/smb2/proto.h" +#include "param/param.h" + static struct { const char *name; uint16_t level; @@ -75,7 +77,7 @@ static struct { /* test fileinfo levels */ -static BOOL torture_smb2_fileinfo(struct smb2_tree *tree) +static bool torture_smb2_fileinfo(struct smb2_tree *tree) { struct smb2_handle hfile, hdir; NTSTATUS status; @@ -103,7 +105,7 @@ static BOOL torture_smb2_fileinfo(struct smb2_tree *tree) file_levels[i].dinfo.query_secdesc.in.secinfo_flags = 0x7; } if (file_levels[i].level == RAW_FILEINFO_SMB2_ALL_EAS) { - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (lp_parm_bool(global_loadparm, NULL, "torture", "samba4", false)) { continue; } file_levels[i].finfo.all_eas.in.continue_flags = @@ -129,17 +131,17 @@ static BOOL torture_smb2_fileinfo(struct smb2_tree *tree) } } - return True; + return true; failed: - return False; + return false; } /* test fsinfo levels */ -static BOOL torture_smb2_fsinfo(struct smb2_tree *tree) +static bool torture_smb2_fsinfo(struct smb2_tree *tree) { int i; NTSTATUS status; @@ -149,7 +151,7 @@ static BOOL torture_smb2_fsinfo(struct smb2_tree *tree) status = smb2_util_roothandle(tree, &handle); if (!NT_STATUS_IS_OK(status)) { printf("Unable to create test directory '%s' - %s\n", DNAME, nt_errstr(status)); - return False; + return false; } for (i=0;i<ARRAY_SIZE(fs_levels);i++) { @@ -158,35 +160,35 @@ static BOOL torture_smb2_fsinfo(struct smb2_tree *tree) fs_levels[i].status = smb2_getinfo_fs(tree, tree, &fs_levels[i].info); if (!NT_STATUS_IS_OK(fs_levels[i].status)) { printf("%s failed - %s\n", fs_levels[i].name, nt_errstr(fs_levels[i].status)); - return False; + return false; } } - return True; + return true; } /* basic testing of all SMB2 getinfo levels */ -BOOL torture_smb2_getinfo(struct torture_context *torture) +bool torture_smb2_getinfo(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; - BOOL ret = True; + bool ret = true; NTSTATUS status; if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } status = torture_setup_complex_file(tree, FNAME); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } torture_setup_complex_file(tree, FNAME ":streamtwo"); status = torture_setup_complex_dir(tree, DNAME); if (!NT_STATUS_IS_OK(status)) { - return False; + return false; } torture_setup_complex_file(tree, DNAME ":streamtwo"); diff --git a/source4/torture/smb2/lock.c b/source4/torture/smb2/lock.c index 9f426c3aa8..98e412817b 100644 --- a/source4/torture/smb2/lock.c +++ b/source4/torture/smb2/lock.c @@ -32,7 +32,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -40,13 +40,13 @@ if ((v) != (correct)) { \ printf("(%s) Incorrect value %s=%d - should be %d\n", \ __location__, #v, v, correct); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) -static BOOL test_valid_request(struct torture_context *torture, struct smb2_tree *tree) +static bool test_valid_request(struct torture_context *torture, struct smb2_tree *tree) { - BOOL ret = True; + bool ret = true; NTSTATUS status; struct smb2_handle h; uint8_t buf[200]; @@ -194,11 +194,11 @@ struct test_lock_read_write_state { NTSTATUS read_h2_status; }; -static BOOL test_lock_read_write(struct torture_context *torture, +static bool test_lock_read_write(struct torture_context *torture, struct smb2_tree *tree, struct test_lock_read_write_state *s) { - BOOL ret = True; + bool ret = true; NTSTATUS status; struct smb2_handle h1, h2; uint8_t buf[200]; @@ -317,7 +317,7 @@ done: return ret; } -static BOOL test_lock_rw_none(struct torture_context *torture, struct smb2_tree *tree) +static bool test_lock_rw_none(struct torture_context *torture, struct smb2_tree *tree) { struct test_lock_read_write_state s = { .fname = "lock_rw_none.dat", @@ -331,7 +331,7 @@ static BOOL test_lock_rw_none(struct torture_context *torture, struct smb2_tree return test_lock_read_write(torture, tree, &s); } -static BOOL test_lock_rw_shared(struct torture_context *torture, struct smb2_tree *tree) +static bool test_lock_rw_shared(struct torture_context *torture, struct smb2_tree *tree) { struct test_lock_read_write_state s = { .fname = "lock_rw_shared.dat", @@ -345,7 +345,7 @@ static BOOL test_lock_rw_shared(struct torture_context *torture, struct smb2_tre return test_lock_read_write(torture, tree, &s); } -static BOOL test_lock_rw_exclusiv(struct torture_context *torture, struct smb2_tree *tree) +static bool test_lock_rw_exclusiv(struct torture_context *torture, struct smb2_tree *tree) { struct test_lock_read_write_state s = { .fname = "lock_rw_exclusiv.dat", diff --git a/source4/torture/smb2/maxwrite.c b/source4/torture/smb2/maxwrite.c index d4a77ad3ca..588a49221e 100644 --- a/source4/torture/smb2/maxwrite.c +++ b/source4/torture/smb2/maxwrite.c @@ -111,7 +111,7 @@ static NTSTATUS torture_smb2_write(TALLOC_CTX *mem_ctx, /* basic testing of SMB2 connection calls */ -BOOL torture_smb2_maxwrite(struct torture_context *torture) +bool torture_smb2_maxwrite(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; @@ -119,17 +119,17 @@ BOOL torture_smb2_maxwrite(struct torture_context *torture) NTSTATUS status; if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } h1 = torture_smb2_create(tree, FNAME); status = torture_smb2_write(mem_ctx, tree, h1); if (!NT_STATUS_IS_OK(status)) { printf("Write failed - %s\n", nt_errstr(status)); - return False; + return false; } talloc_free(mem_ctx); - return True; + return true; } diff --git a/source4/torture/smb2/notify.c b/source4/torture/smb2/notify.c index 505b316d8e..cabe81ca71 100644 --- a/source4/torture/smb2/notify.c +++ b/source4/torture/smb2/notify.c @@ -33,7 +33,7 @@ if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -41,7 +41,7 @@ if ((v) != (correct)) { \ printf("(%s) Incorrect value %s=%d - should be %d\n", \ __location__, #v, v, correct); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -49,15 +49,15 @@ if (!field.s || strcmp(field.s, value)) { \ printf("(%s) %s [%s] != %s\n", \ __location__, #field, field.s, value); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) #define FNAME "smb2-notify01.dat" -static BOOL test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree) +static bool test_valid_request(TALLOC_CTX *mem_ctx, struct smb2_tree *tree) { - BOOL ret = True; + bool ret = true; NTSTATUS status; struct smb2_handle dh; struct smb2_notify n; @@ -188,14 +188,14 @@ done: /* basic testing of SMB2 notify */ -BOOL torture_smb2_notify(struct torture_context *torture) +bool torture_smb2_notify(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; - BOOL ret = True; + bool ret = true; if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } ret &= test_valid_request(mem_ctx, tree); diff --git a/source4/torture/smb2/scan.c b/source4/torture/smb2/scan.c index 83893608f9..f3e4d5cd36 100644 --- a/source4/torture/smb2/scan.c +++ b/source4/torture/smb2/scan.c @@ -35,7 +35,7 @@ /* scan for valid SMB2 getinfo levels */ -BOOL torture_smb2_getinfo_scan(struct torture_context *torture) +bool torture_smb2_getinfo_scan(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; @@ -45,20 +45,20 @@ BOOL torture_smb2_getinfo_scan(struct torture_context *torture) int c, i; if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } status = torture_setup_complex_file(tree, FNAME); if (!NT_STATUS_IS_OK(status)) { printf("Failed to setup complex file '%s'\n", FNAME); - return False; + return false; } torture_setup_complex_file(tree, FNAME ":2ndstream"); status = torture_setup_complex_dir(tree, DNAME); if (!NT_STATUS_IS_OK(status)) { printf("Failed to setup complex dir '%s'\n", DNAME); - return False; + return false; } torture_setup_complex_file(tree, DNAME ":2ndstream"); @@ -97,13 +97,13 @@ BOOL torture_smb2_getinfo_scan(struct torture_context *torture) talloc_free(mem_ctx); - return True; + return true; } /* scan for valid SMB2 setinfo levels */ -BOOL torture_smb2_setinfo_scan(struct torture_context *torture) +bool torture_smb2_setinfo_scan(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; @@ -113,13 +113,13 @@ BOOL torture_smb2_setinfo_scan(struct torture_context *torture) int c, i; if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } status = torture_setup_complex_file(tree, FNAME); if (!NT_STATUS_IS_OK(status)) { printf("Failed to setup complex file '%s'\n", FNAME); - return False; + return false; } torture_setup_complex_file(tree, FNAME ":2ndstream"); @@ -143,14 +143,14 @@ BOOL torture_smb2_setinfo_scan(struct torture_context *torture) talloc_free(mem_ctx); - return True; + return true; } /* scan for valid SMB2 scan levels */ -BOOL torture_smb2_find_scan(struct torture_context *torture) +bool torture_smb2_find_scan(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; @@ -160,13 +160,13 @@ BOOL torture_smb2_find_scan(struct torture_context *torture) int i; if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } status = smb2_util_roothandle(tree, &handle); if (!NT_STATUS_IS_OK(status)) { printf("Failed to open roothandle - %s\n", nt_errstr(status)); - return False; + return false; } ZERO_STRUCT(io); @@ -191,13 +191,13 @@ BOOL torture_smb2_find_scan(struct torture_context *torture) talloc_free(mem_ctx); - return True; + return true; } /* scan for valid SMB2 opcodes */ -BOOL torture_smb2_scan(struct torture_context *torture) +bool torture_smb2_scan(struct torture_context *torture) { TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_tree *tree; @@ -212,13 +212,13 @@ BOOL torture_smb2_scan(struct torture_context *torture) event_context_find(mem_ctx)); if (!NT_STATUS_IS_OK(status)) { printf("Connection failed - %s\n", nt_errstr(status)); - return False; + return false; } tree->session->transport->options.timeout = 3; for (opcode=0;opcode<1000;opcode++) { - req = smb2_request_init_tree(tree, opcode, 2, False, 0); + req = smb2_request_init_tree(tree, opcode, 2, false, 0); SSVAL(req->out.body, 0, 0); smb2_transport_send(req); if (!smb2_request_receive(req)) { @@ -227,7 +227,7 @@ BOOL torture_smb2_scan(struct torture_context *torture) event_context_find(mem_ctx)); if (!NT_STATUS_IS_OK(status)) { printf("Connection failed - %s\n", nt_errstr(status)); - return False; + return false; } tree->session->transport->options.timeout = 3; } else { @@ -238,5 +238,5 @@ BOOL torture_smb2_scan(struct torture_context *torture) talloc_free(mem_ctx); - return True; + return true; } diff --git a/source4/torture/smb2/setinfo.c b/source4/torture/smb2/setinfo.c index 88e8d07604..6a81f13f67 100644 --- a/source4/torture/smb2/setinfo.c +++ b/source4/torture/smb2/setinfo.c @@ -36,10 +36,10 @@ for each call we test that it succeeds, and where possible test for consistency between the calls. */ -BOOL torture_smb2_setinfo(struct torture_context *torture) +bool torture_smb2_setinfo(struct torture_context *torture) { struct smb2_tree *tree; - BOOL ret = True; + bool ret = true; TALLOC_CTX *mem_ctx = talloc_new(NULL); struct smb2_handle handle; char *fname; @@ -60,7 +60,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture) fname_new = talloc_asprintf(mem_ctx, BASEDIR "fnum_test_new_%d.txt", n); if (!torture_smb2_connection(mem_ctx, &tree)) { - return False; + return false; } #define RECREATE_FILE(fname) do { \ @@ -69,7 +69,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture) if (!NT_STATUS_IS_OK(status)) { \ printf("(%s) ERROR: open of %s failed (%s)\n", \ __location__, fname, nt_errstr(status)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -87,7 +87,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture) if (!NT_STATUS_EQUAL(status, rightstatus)) { \ printf("(%s) %s - %s (should be %s)\n", __location__, #call, \ nt_errstr(status), nt_errstr(rightstatus)); \ - ret = False; \ + ret = false; \ goto done; \ } \ } while (0) @@ -99,7 +99,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture) status2 = smb2_getinfo_file(tree, mem_ctx, &finfo2); \ if (!NT_STATUS_IS_OK(status2)) { \ printf("(%s) %s - %s\n", __location__, #call, nt_errstr(status2)); \ - ret = False; \ + ret = false; \ goto done; \ } \ }} while (0) @@ -111,7 +111,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture) call_name, #stype, #field, \ (uint_t)value, (uint_t)finfo2.stype.out.field); \ torture_smb2_all_info(tree, handle); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -125,7 +125,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture) printf("\t%s", timestring(mem_ctx, value)); \ printf("\t%s\n", nt_time_string(mem_ctx, finfo2.stype.out.field)); \ torture_smb2_all_info(tree, handle); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -133,7 +133,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture) if (!NT_STATUS_EQUAL(status, correct)) { \ printf("(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ + ret = false; \ goto done; \ }} while (0) @@ -262,7 +262,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture) NDR_PRINT_DEBUG(security_descriptor, finfo2.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd); - ret = False; + ret = false; } printf("remove it again\n"); @@ -281,7 +281,7 @@ BOOL torture_smb2_setinfo(struct torture_context *torture) NDR_PRINT_DEBUG(security_descriptor, finfo2.query_secdesc.out.sd); printf("expected:\n"); NDR_PRINT_DEBUG(security_descriptor, sd); - ret = False; + ret = false; } done: diff --git a/source4/torture/smb2/util.c b/source4/torture/smb2/util.c index 5e680fbcec..705f10a841 100644 --- a/source4/torture/smb2/util.c +++ b/source4/torture/smb2/util.c @@ -26,6 +26,10 @@ #include "lib/events/events.h" #include "system/time.h" #include "librpc/gen_ndr/ndr_security.h" +#include "param/param.h" + +#include "torture/torture.h" +#include "torture/smb2/proto.h" /* @@ -90,7 +94,7 @@ NTSTATUS smb2_util_write(struct smb2_tree *tree, create a complex file/dir using the SMB2 protocol */ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, - struct smb2_handle *handle, BOOL dir) + struct smb2_handle *handle, bool dir) { TALLOC_CTX *tmp_ctx = talloc_new(tree); char buf[7] = "abc"; @@ -195,7 +199,7 @@ static NTSTATUS smb2_create_complex(struct smb2_tree *tree, const char *fname, NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, struct smb2_handle *handle) { - return smb2_create_complex(tree, fname, handle, False); + return smb2_create_complex(tree, fname, handle, false); } /* @@ -204,7 +208,7 @@ NTSTATUS smb2_create_complex_file(struct smb2_tree *tree, const char *fname, NTSTATUS smb2_create_complex_dir(struct smb2_tree *tree, const char *fname, struct smb2_handle *handle) { - return smb2_create_complex(tree, fname, handle, True); + return smb2_create_complex(tree, fname, handle, true); } /* @@ -298,11 +302,11 @@ void torture_smb2_all_info(struct smb2_tree *tree, struct smb2_handle handle) /* open a smb2 connection */ -BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) +bool torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) { NTSTATUS status; - const char *host = lp_parm_string(-1, "torture", "host"); - const char *share = lp_parm_string(-1, "torture", "share"); + const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host"); + const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share"); struct cli_credentials *credentials = cmdline_credentials; status = smb2_connect(mem_ctx, host, share, credentials, tree, @@ -310,9 +314,9 @@ BOOL torture_smb2_connection(TALLOC_CTX *mem_ctx, struct smb2_tree **tree) if (!NT_STATUS_IS_OK(status)) { printf("Failed to connect to SMB2 share \\\\%s\\%s - %s\n", host, share, nt_errstr(status)); - return False; + return false; } - return True; + return true; } diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index d461828431..ea563f7d63 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -34,6 +34,7 @@ #include "build.h" #include "lib/util/dlinklist.h" #include "librpc/rpc/dcerpc.h" +#include "param/param.h" static bool run_matching(struct torture_context *torture, const char *prefix, @@ -130,33 +131,33 @@ static void parse_dns(const char *dns) /* retrievieng the userdn */ p = strchr_m(dns, '#'); if (!p) { - lp_set_cmdline("torture:ldap_userdn", ""); - lp_set_cmdline("torture:ldap_basedn", ""); - lp_set_cmdline("torture:ldap_secret", ""); + lp_set_cmdline(global_loadparm, "torture:ldap_userdn", ""); + lp_set_cmdline(global_loadparm, "torture:ldap_basedn", ""); + lp_set_cmdline(global_loadparm, "torture:ldap_secret", ""); return; } userdn = strndup(dns, p - dns); - lp_set_cmdline("torture:ldap_userdn", userdn); + lp_set_cmdline(global_loadparm, "torture:ldap_userdn", userdn); /* retrieve the basedn */ d = p + 1; p = strchr_m(d, '#'); if (!p) { - lp_set_cmdline("torture:ldap_basedn", ""); - lp_set_cmdline("torture:ldap_secret", ""); + lp_set_cmdline(global_loadparm, "torture:ldap_basedn", ""); + lp_set_cmdline(global_loadparm, "torture:ldap_secret", ""); return; } basedn = strndup(d, p - d); - lp_set_cmdline("torture:ldap_basedn", basedn); + lp_set_cmdline(global_loadparm, "torture:ldap_basedn", basedn); /* retrieve the secret */ p = p + 1; if (!p) { - lp_set_cmdline("torture:ldap_secret", ""); + lp_set_cmdline(global_loadparm, "torture:ldap_secret", ""); return; } secret = strdup(p); - lp_set_cmdline("torture:ldap_secret", secret); + lp_set_cmdline(global_loadparm, "torture:ldap_secret", secret); printf ("%s - %s - %s\n", userdn, basedn, secret); @@ -168,6 +169,9 @@ static void print_test_list(void) struct torture_suite *s; struct torture_tcase *t; + if (torture_root == NULL) + return; + for (o = torture_root->children; o; o = o->next) { for (s = o->children; s; s = s->next) { printf("%s-%s\n", o->name, s->name); @@ -179,7 +183,7 @@ static void print_test_list(void) } } -static void usage(poptContext pc) +_NORETURN_ static void usage(poptContext pc) { struct torture_suite *o; struct torture_suite *s; @@ -238,6 +242,11 @@ static void usage(poptContext pc) printf("Tests are:"); + if (torture_root == NULL) { + printf("NO TESTS LOADED\n"); + exit(1); + } + for (o = torture_root->children; o; o = o->next) { printf("\n%s (%s):\n ", o->description, o->name); @@ -266,7 +275,7 @@ static void usage(poptContext pc) exit(1); } -static void max_runtime_handler(int sig) +_NORETURN_ static void max_runtime_handler(int sig) { DEBUG(0,("maximum runtime exceeded for smbtorture - terminating\n")); exit(1); @@ -275,22 +284,22 @@ static void max_runtime_handler(int sig) struct timeval last_suite_started; static void simple_suite_start(struct torture_context *ctx, - struct torture_suite *suite) + struct torture_suite *suite) { last_suite_started = timeval_current(); printf("Running %s\n", suite->name); } static void simple_suite_finish(struct torture_context *ctx, - struct torture_suite *suite) + struct torture_suite *suite) { printf("%s took %g secs\n\n", suite->name, timeval_elapsed(&last_suite_started)); } -static void simple_test_result (struct torture_context *context, - enum torture_result res, const char *reason) +static void simple_test_result(struct torture_context *context, + enum torture_result res, const char *reason) { switch (res) { case TORTURE_OK: @@ -309,14 +318,14 @@ static void simple_test_result (struct torture_context *context, } } -static void simple_comment (struct torture_context *test, - const char *comment) +static void simple_comment(struct torture_context *test, + const char *comment) { printf("%s", comment); } static void simple_warning(struct torture_context *test, - const char *comment) + const char *comment) { fprintf(stderr, "WARNING: %s\n", comment); } @@ -335,19 +344,19 @@ static void subunit_init(struct torture_context *ctx) } static void subunit_suite_start(struct torture_context *ctx, - struct torture_suite *suite) + struct torture_suite *suite) { } -static void subunit_test_start (struct torture_context *ctx, - struct torture_tcase *tcase, - struct torture_test *test) +static void subunit_test_start(struct torture_context *ctx, + struct torture_tcase *tcase, + struct torture_test *test) { printf("test: %s\n", test->name); } -static void subunit_test_result (struct torture_context *context, - enum torture_result res, const char *reason) +static void subunit_test_result(struct torture_context *context, + enum torture_result res, const char *reason) { switch (res) { case TORTURE_OK: @@ -368,22 +377,29 @@ static void subunit_test_result (struct torture_context *context, printf("\n"); } -static void subunit_comment (struct torture_context *test, - const char *comment) +static void subunit_comment(struct torture_context *test, + const char *comment) { fprintf(stderr, "%s", comment); } +static void subunit_warning(struct torture_context *test, + const char *comment) +{ + fprintf(stderr, "WARNING!: %s\n", comment); +} + const static struct torture_ui_ops subunit_ui_ops = { .init = subunit_init, .comment = subunit_comment, + .warning = subunit_warning, .test_start = subunit_test_start, .test_result = subunit_test_result, .suite_start = subunit_suite_start }; static void quiet_suite_start(struct torture_context *ctx, - struct torture_suite *suite) + struct torture_suite *suite) { int i; ctx->quiet = true; @@ -393,13 +409,13 @@ static void quiet_suite_start(struct torture_context *ctx, } static void quiet_suite_finish(struct torture_context *ctx, - struct torture_suite *suite) + struct torture_suite *suite) { putchar('\n'); } -static void quiet_test_result (struct torture_context *context, - enum torture_result res, const char *reason) +static void quiet_test_result(struct torture_context *context, + enum torture_result res, const char *reason) { fflush(stdout); switch (res) { @@ -442,7 +458,7 @@ void run_shell(struct torture_context *tctx) fprintf(stderr, "Usage: set <variable> <value>\n"); } else { char *name = talloc_asprintf(NULL, "torture:%s", argv[1]); - lp_set_cmdline(name, argv[2]); + lp_set_cmdline(global_loadparm, name, argv[2]); talloc_free(name); } } else if (!strcmp(argv[0], "help")) { @@ -477,9 +493,10 @@ int main(int argc,char *argv[]) static const char *target = "other"; struct dcerpc_binding *binding_struct; NTSTATUS status; - int shell = False; + int shell = false; static const char *ui_ops_name = "simple"; const char *basedir = NULL; + const char *extra_module = NULL; static int list_tests = 0; char *host = NULL, *share = NULL; enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS, OPT_LIST, @@ -502,7 +519,8 @@ int main(int argc,char *argv[]) {"parse-dns", 'D', POPT_ARG_STRING, NULL, OPT_DNS, "parse-dns", NULL}, {"dangerous", 'X', POPT_ARG_NONE, NULL, OPT_DANGEROUS, "run dangerous tests (eg. wiping out password database)", NULL}, - {"shell", 0, POPT_ARG_NONE, &shell, True, "Run shell", NULL}, + {"load-module", 0, POPT_ARG_STRING, &extra_module, 0, "load tests from DSO file", "SOFILE"}, + {"shell", 0, POPT_ARG_NONE, &shell, true, "Run shell", NULL}, {"target", 'T', POPT_ARG_STRING, &target, 0, "samba3|samba4|other", NULL}, {"async", 'a', POPT_ARG_NONE, NULL, OPT_ASYNC, "run async tests", NULL}, @@ -530,36 +548,36 @@ int main(int argc,char *argv[]) while((opt = poptGetNextOpt(pc)) != -1) { switch (opt) { case OPT_LOADFILE: - lp_set_cmdline("torture:loadfile", poptGetOptArg(pc)); + lp_set_cmdline(global_loadparm, "torture:loadfile", poptGetOptArg(pc)); break; case OPT_UNCLIST: - lp_set_cmdline("torture:unclist", poptGetOptArg(pc)); + lp_set_cmdline(global_loadparm, "torture:unclist", poptGetOptArg(pc)); break; case OPT_TIMELIMIT: - lp_set_cmdline("torture:timelimit", poptGetOptArg(pc)); + lp_set_cmdline(global_loadparm, "torture:timelimit", poptGetOptArg(pc)); break; case OPT_NUMPROGS: - lp_set_cmdline("torture:nprocs", poptGetOptArg(pc)); + lp_set_cmdline(global_loadparm, "torture:nprocs", poptGetOptArg(pc)); break; case OPT_DNS: parse_dns(poptGetOptArg(pc)); break; case OPT_DANGEROUS: - lp_set_cmdline("torture:dangerous", "Yes"); + lp_set_cmdline(global_loadparm, "torture:dangerous", "Yes"); break; case OPT_ASYNC: - lp_set_cmdline("torture:async", "Yes"); + lp_set_cmdline(global_loadparm, "torture:async", "Yes"); break; case OPT_SMB_PORTS: - lp_set_cmdline("smb ports", poptGetOptArg(pc)); + lp_set_cmdline(global_loadparm, "smb ports", poptGetOptArg(pc)); break; } } if (strcmp(target, "samba3") == 0) { - lp_set_cmdline("torture:samba3", "true"); + lp_set_cmdline(global_loadparm, "torture:samba3", "true"); } else if (strcmp(target, "samba4") == 0) { - lp_set_cmdline("torture:samba4", "true"); + lp_set_cmdline(global_loadparm, "torture:samba4", "true"); } if (max_runtime) { @@ -572,9 +590,24 @@ int main(int argc,char *argv[]) alarm(max_runtime); } - torture_init(); ldb_global_init(); + if (extra_module != NULL) { + init_module_fn fn = load_module(talloc_autofree_context(), poptGetOptArg(pc)); + + if (fn == NULL) + d_printf("Unable to load module from %s\n", poptGetOptArg(pc)); + else { + status = fn(); + if (NT_STATUS_IS_ERR(status)) { + d_printf("Error initializing module %s: %s\n", + poptGetOptArg(pc), nt_errstr(status)); + } + } + } else { + torture_init(); + } + if (list_tests) { print_test_list(); return 0; @@ -609,12 +642,14 @@ int main(int argc,char *argv[]) usage(pc); return false; } - lp_set_cmdline("torture:host", binding_struct->host); - lp_set_cmdline("torture:share", "IPC$"); - lp_set_cmdline("torture:binding", argv_new[1]); + lp_set_cmdline(global_loadparm, "torture:host", binding_struct->host); + if (lp_parm_string(global_loadparm, NULL, "torture", "share") == NULL) + lp_set_cmdline(global_loadparm, "torture:share", "IPC$"); + lp_set_cmdline(global_loadparm, "torture:binding", argv_new[1]); } else { - lp_set_cmdline("torture:host", host); - lp_set_cmdline("torture:share", share); + lp_set_cmdline(global_loadparm, "torture:host", host); + lp_set_cmdline(global_loadparm, "torture:share", share); + lp_set_cmdline(global_loadparm, "torture:binding", host); } if (!strcmp(ui_ops_name, "simple")) { @@ -629,7 +664,20 @@ int main(int argc,char *argv[]) } torture = torture_context_init(talloc_autofree_context(), ui_ops); - torture->outputdir = basedir; + if (basedir != NULL) { + if (basedir[0] != '/') { + fprintf(stderr, "Please specify an absolute path to --basedir\n"); + return 1; + } + torture->outputdir = basedir; + } else { + char *pwd = talloc_size(torture, PATH_MAX); + if (!getcwd(pwd, PATH_MAX)) { + fprintf(stderr, "Unable to determine current working directory\n"); + return 1; + } + torture->outputdir = pwd; + } if (argc_new == 0) { printf("You must specify a test to run, or 'ALL'\n"); @@ -643,7 +691,7 @@ int main(int argc,char *argv[]) } } - if (torture->returncode) { + if (torture->returncode && correct) { return(0); } else { return(1); diff --git a/source4/torture/torture.c b/source4/torture/torture.c index 9231fe45ed..44a0d3b4c2 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -25,6 +25,7 @@ #include "lib/util/dlinklist.h" #include "auth/credentials/credentials.h" #include "lib/cmdline/popt_common.h" +#include "param/param.h" _PUBLIC_ int torture_numops=10; _PUBLIC_ int torture_entries=1000; @@ -39,6 +40,9 @@ bool torture_register_suite(struct torture_suite *suite) if (!suite) return true; + if (torture_root == NULL) + torture_root = talloc_zero(talloc_autofree_context(), struct torture_suite); + return torture_suite_add_suite(torture_root, suite); } @@ -61,11 +65,8 @@ struct torture_context *torture_context_init(TALLOC_CTX *mem_ctx, int torture_init(void) { init_module_fn static_init[] = STATIC_torture_MODULES; - init_module_fn *shared_init = load_samba_modules(NULL, "torture"); + init_module_fn *shared_init = load_samba_modules(NULL, global_loadparm, "torture"); - torture_root = talloc_zero(talloc_autofree_context(), - struct torture_suite); - run_init_functions(static_init); run_init_functions(shared_init); diff --git a/source4/torture/ui.c b/source4/torture/ui.c index 92e03fff19..5d00b664f4 100644 --- a/source4/torture/ui.c +++ b/source4/torture/ui.c @@ -22,6 +22,27 @@ #include "torture/ui.h" #include "torture/torture.h" #include "lib/util/dlinklist.h" +#include "param/param.h" +#include "system/filesys.h" + +/** + create a temporary directory. +*/ +_PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx, + const char *prefix, + char **tempdir) +{ + SMB_ASSERT(tctx->outputdir != NULL); + + *tempdir = talloc_asprintf(tctx, "%s/%s.XXXXXX", tctx->outputdir, prefix); + NT_STATUS_HAVE_NO_MEMORY(*tempdir); + + if (mkdtemp(*tempdir) == NULL) { + return map_nt_error_from_unix(errno); + } + + return NT_STATUS_OK; +} void torture_comment(struct torture_context *context, const char *comment, ...) { @@ -62,6 +83,11 @@ void torture_result(struct torture_context *context, va_start(ap, fmt); + if (context->last_reason) { + torture_warning(context, "%s", context->last_reason); + talloc_free(context->last_reason); + } + context->last_result = result; context->last_reason = talloc_vasprintf(context, fmt, ap); va_end(ap); @@ -79,20 +105,20 @@ struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name) } void torture_tcase_set_fixture(struct torture_tcase *tcase, - BOOL (*setup) (struct torture_context *, void **), - BOOL (*teardown) (struct torture_context *, void *)) + bool (*setup) (struct torture_context *, void **), + bool (*teardown) (struct torture_context *, void *)) { tcase->setup = setup; tcase->teardown = teardown; } static bool wrap_test_with_testcase(struct torture_context *torture_ctx, - struct torture_tcase *tcase, - struct torture_test *test) + struct torture_tcase *tcase, + struct torture_test *test) { bool (*fn) (struct torture_context *, - const void *tcase_data, - const void *test_data); + const void *tcase_data, + const void *test_data); fn = test->fn; @@ -112,7 +138,7 @@ struct torture_test *torture_tcase_add_test(struct torture_tcase *tcase, test->description = NULL; test->run = wrap_test_with_testcase; test->fn = run; - test->dangerous = False; + test->dangerous = false; test->data = data; DLIST_ADD_END(tcase->tests, test, struct torture_test *); @@ -129,7 +155,7 @@ bool torture_suite_init_tcase(struct torture_suite *suite, tcase->description = NULL; tcase->setup = NULL; tcase->teardown = NULL; - tcase->fixture_persistent = True; + tcase->fixture_persistent = true; tcase->tests = NULL; DLIST_ADD_END(suite->testcases, tcase, struct torture_tcase *); @@ -149,10 +175,10 @@ struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite, return tcase; } -BOOL torture_run_suite(struct torture_context *context, +bool torture_run_suite(struct torture_context *context, struct torture_suite *suite) { - BOOL ret = True; + bool ret = true; struct torture_tcase *tcase; struct torture_suite *tsuite; char *old_testname; @@ -164,7 +190,7 @@ BOOL torture_run_suite(struct torture_context *context, old_testname = context->active_testname; if (old_testname != NULL) context->active_testname = talloc_asprintf(context, "%s-%s", - old_testname, suite->name); + old_testname, suite->name); else context->active_testname = talloc_strdup(context, suite->name); @@ -219,46 +245,58 @@ void torture_ui_test_result(struct torture_context *context, context->returncode = false; } -static BOOL internal_torture_run_test(struct torture_context *context, +static bool internal_torture_run_test(struct torture_context *context, struct torture_tcase *tcase, struct torture_test *test, - BOOL already_setup) + bool already_setup) { - BOOL ret; + bool success; char *old_testname; - if (test->dangerous && !torture_setting_bool(context, "dangerous", False)) { - torture_result(context, TORTURE_SKIP, - "disabled %s - enable dangerous tests to use", test->name); - return True; - } - - if (!already_setup && tcase->setup && - !tcase->setup(context, &(tcase->data))) - return False; - if (tcase == NULL || strcmp(test->name, tcase->name) != 0) { old_testname = context->active_testname; - context->active_testname = talloc_asprintf(context, "%s-%s", - old_testname, test->name); + context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, test->name); } + context->active_tcase = tcase; context->active_test = test; torture_ui_test_start(context, tcase, test); - context->last_reason = NULL; context->last_result = TORTURE_OK; - ret = test->run(context, tcase, test); - if (!ret && context->last_result == TORTURE_OK) { - if (context->last_reason == NULL) - context->last_reason = talloc_strdup(context, "Unknown error/failure"); + if (!already_setup && tcase->setup && + !tcase->setup(context, &(tcase->data))) { + if (context->last_reason == NULL) + context->last_reason = talloc_strdup(context, "Setup failure"); context->last_result = TORTURE_ERROR; + success = false; + } else if (test->dangerous && + !torture_setting_bool(context, "dangerous", false)) { + context->last_result = TORTURE_SKIP; + context->last_reason = talloc_asprintf(context, + "disabled %s - enable dangerous tests to use", test->name); + success = true; + } else { + success = test->run(context, tcase, test); + + if (!success && context->last_result == TORTURE_OK) { + if (context->last_reason == NULL) + context->last_reason = talloc_strdup(context, "Unknown error/failure"); + context->last_result = TORTURE_ERROR; + } + } + + if (!already_setup && tcase->teardown && !tcase->teardown(context, tcase->data)) { + if (context->last_reason == NULL) + context->last_reason = talloc_strdup(context, "Setup failure"); + context->last_result = TORTURE_ERROR; + success = false; } - torture_ui_test_result(context, context->last_result, context->last_reason); + torture_ui_test_result(context, context->last_result, + context->last_reason); talloc_free(context->last_reason); @@ -269,34 +307,35 @@ static BOOL internal_torture_run_test(struct torture_context *context, context->active_test = NULL; context->active_tcase = NULL; - if (!already_setup && tcase->teardown && !tcase->teardown(context, tcase->data)) - return False; - - return ret; + return success; } -BOOL torture_run_tcase(struct torture_context *context, +bool torture_run_tcase(struct torture_context *context, struct torture_tcase *tcase) { - BOOL ret = True; + bool ret = true; char *old_testname; struct torture_test *test; context->level++; context->active_tcase = tcase; - if (context->ui_ops->tcase_start) + if (context->ui_ops->tcase_start) context->ui_ops->tcase_start(context, tcase); if (tcase->fixture_persistent && tcase->setup && !tcase->setup(context, &tcase->data)) { - ret = False; + /* FIXME: Use torture ui ops for reporting this error */ + fprintf(stderr, "Setup failed: "); + if (context->last_reason != NULL) + fprintf(stderr, "%s", context->last_reason); + fprintf(stderr, "\n"); + ret = false; goto done; } old_testname = context->active_testname; - context->active_testname = talloc_asprintf(context, "%s-%s", - old_testname, tcase->name); + context->active_testname = talloc_asprintf(context, "%s-%s", old_testname, tcase->name); for (test = tcase->tests; test; test = test->next) { ret &= internal_torture_run_test(context, tcase, test, tcase->fixture_persistent); @@ -306,7 +345,7 @@ BOOL torture_run_tcase(struct torture_context *context, if (tcase->fixture_persistent && tcase->teardown && !tcase->teardown(context, tcase->data)) - ret = False; + ret = false; done: context->active_tcase = NULL; @@ -319,35 +358,35 @@ done: return ret; } -BOOL torture_run_test(struct torture_context *context, +bool torture_run_test(struct torture_context *context, struct torture_tcase *tcase, struct torture_test *test) { - return internal_torture_run_test(context, tcase, test, False); + return internal_torture_run_test(context, tcase, test, false); } int torture_setting_int(struct torture_context *test, const char *name, int default_value) { - return lp_parm_int(-1, "torture", name, default_value); + return lp_parm_int(global_loadparm, NULL, "torture", name, default_value); } double torture_setting_double(struct torture_context *test, const char *name, double default_value) { - return lp_parm_double(-1, "torture", name, default_value); + return lp_parm_double(global_loadparm, NULL, "torture", name, default_value); } bool torture_setting_bool(struct torture_context *test, const char *name, bool default_value) { - return lp_parm_bool(-1, "torture", name, default_value); + return lp_parm_bool(global_loadparm, NULL, "torture", name, default_value); } const char *torture_setting_string(struct torture_context *test, const char *name, const char *default_value) { - const char *ret = lp_parm_string(-1, "torture", name); + const char *ret = lp_parm_string(global_loadparm, NULL, "torture", name); if (ret == NULL) return default_value; diff --git a/source4/torture/ui.h b/source4/torture/ui.h index 289fad5930..71c2122315 100644 --- a/source4/torture/ui.h +++ b/source4/torture/ui.h @@ -87,7 +87,7 @@ struct torture_context bool returncode; - char *outputdir; + const char *outputdir; int level; struct event_context *ev; }; diff --git a/source4/torture/unix/unix_info2.c b/source4/torture/unix/unix_info2.c index 1e063fbe8f..882dc7a084 100644 --- a/source4/torture/unix/unix_info2.c +++ b/source4/torture/unix/unix_info2.c @@ -67,7 +67,7 @@ static struct smbcli_state *connect_to_server(struct torture_context *tctx) return cli; } -static BOOL check_unix_info2(struct torture_context *torture, +static bool check_unix_info2(struct torture_context *torture, struct unix_info2 *info2) { printf("\tcreate_time=0x%016llu flags=0x%08x mask=0x%08x\n", @@ -75,7 +75,7 @@ static BOOL check_unix_info2(struct torture_context *torture, info2->file_flags, info2->flags_mask); if (info2->file_flags == 0) { - return True; + return true; } /* If we have any file_flags set, they must be within the range @@ -88,7 +88,7 @@ static BOOL check_unix_info2(struct torture_context *torture, info2->file_flags, info2->flags_mask); } - return True; + return true; } static NTSTATUS set_path_info2(void *mem_ctx, @@ -122,7 +122,7 @@ static NTSTATUS set_path_info2(void *mem_ctx, return smb_raw_setpathinfo(cli->tree, &sfinfo); } -static BOOL query_file_path_info2(void *mem_ctx, +static bool query_file_path_info2(void *mem_ctx, struct torture_context *torture, struct smbcli_state *cli, int fnum, @@ -163,13 +163,13 @@ static BOOL query_file_path_info2(void *mem_ctx, info2->flags_mask = finfo.unix_info2.out.flags_mask; if (!check_unix_info2(torture, info2)) { - return False; + return false; } - return True; + return true; } -static BOOL query_file_info2(void *mem_ctx, +static bool query_file_info2(void *mem_ctx, struct torture_context *torture, struct smbcli_state *cli, int fnum, @@ -179,7 +179,7 @@ static BOOL query_file_info2(void *mem_ctx, fnum, NULL, info2); } -static BOOL query_path_info2(void *mem_ctx, +static bool query_path_info2(void *mem_ctx, struct torture_context *torture, struct smbcli_state *cli, const char *fname, @@ -189,7 +189,7 @@ static BOOL query_path_info2(void *mem_ctx, -1, fname, info2); } -static BOOL search_callback(void *private, const union smb_search_data *fdata) +static bool search_callback(void *private, const union smb_search_data *fdata) { struct unix_info2 *info2 = (struct unix_info2 *)private; @@ -210,10 +210,10 @@ static BOOL search_callback(void *private, const union smb_search_data *fdata) info2->file_flags = fdata->unix_info2.file_flags; info2->flags_mask = fdata->unix_info2.flags_mask; - return True; + return true; } -static BOOL find_single_info2(void *mem_ctx, +static bool find_single_info2(void *mem_ctx, struct torture_context *torture, struct smbcli_state *cli, const char *fname, @@ -267,7 +267,7 @@ static void set_no_metadata_change(struct unix_info2 *info2) ((uint64_t)SMB_SIZE_NO_CHANGE_HI << 32) | SMB_SIZE_NO_CHANGE_LO; } -static BOOL verify_setinfo_flags(void *mem_ctx, +static bool verify_setinfo_flags(void *mem_ctx, struct torture_context *torture, struct smbcli_state *cli, const char *fname) @@ -276,11 +276,11 @@ static BOOL verify_setinfo_flags(void *mem_ctx, uint32_t smb_fmask; int i; - BOOL ret = True; + bool ret = true; NTSTATUS status; if (!query_path_info2(mem_ctx, torture, cli, fname, &info2)) { - return False; + return false; } smb_fmask = info2.flags_mask; @@ -302,7 +302,7 @@ static BOOL verify_setinfo_flags(void *mem_ctx, if (!query_path_info2(mem_ctx, torture, cli, fname, &info2)) { - return False; + return false; } ASSERT_FLAGS_MATCH(&info2, 1 << i); @@ -339,7 +339,7 @@ static int create_file(struct smbcli_state *cli, const char * fname) 0, 0); } -static BOOL match_info2(struct torture_context *torture, +static bool match_info2(struct torture_context *torture, const struct unix_info2 *pinfo, const struct unix_info2 *finfo) { @@ -382,13 +382,13 @@ static BOOL match_info2(struct torture_context *torture, torture_assert_u64_equal(torture, finfo->create_time, pinfo->create_time, "create_time mismatch"); - return True; + return true; } #define FILENAME "\\smb_unix_info2.txt" -BOOL unix_torture_unix_info2(struct torture_context *torture) +bool unix_torture_unix_info2(struct torture_context *torture) { void *mem_ctx; struct smbcli_state *cli; @@ -401,7 +401,7 @@ BOOL unix_torture_unix_info2(struct torture_context *torture) if (!(cli = connect_to_server(torture))) { talloc_free(mem_ctx); - return False; + return false; } smbcli_unlink(cli->tree, FILENAME); @@ -442,7 +442,7 @@ BOOL unix_torture_unix_info2(struct torture_context *torture) smbcli_unlink(cli->tree, FILENAME); torture_close_connection(cli); talloc_free(mem_ctx); - return True; + return true; fail: @@ -450,7 +450,7 @@ fail: smbcli_unlink(cli->tree, FILENAME); torture_close_connection(cli); talloc_free(mem_ctx); - return False; + return false; } diff --git a/source4/torture/unix/whoami.c b/source4/torture/unix/whoami.c index 8322e57bd1..f45d2345db 100644 --- a/source4/torture/unix/whoami.c +++ b/source4/torture/unix/whoami.c @@ -24,6 +24,7 @@ #include "libcli/raw/interfaces.h" #include "lib/cmdline/popt_common.h" #include "auth/credentials/credentials.h" +#include "param/param.h" /* Size (in bytes) of the required fields in the SMBwhoami response. */ #define WHOAMI_REQUIRED_SIZE 40 @@ -71,8 +72,8 @@ static struct smbcli_state *connect_to_server(void *mem_ctx, NTSTATUS status; struct smbcli_state *cli; - const char *host = lp_parm_string(-1, "torture", "host"); - const char *share = lp_parm_string(-1, "torture", "share"); + const char *host = lp_parm_string(global_loadparm, NULL, "torture", "host"); + const char *share = lp_parm_string(global_loadparm, NULL, "torture", "share"); status = smbcli_full_connection(mem_ctx, &cli, host, share, NULL, @@ -87,7 +88,7 @@ static struct smbcli_state *connect_to_server(void *mem_ctx, return cli; } -static BOOL sid_parse(void *mem_ctx, +static bool sid_parse(void *mem_ctx, struct torture_context *torture, DATA_BLOB *data, size_t *offset, struct dom_sid **psid) @@ -125,10 +126,10 @@ static BOOL sid_parse(void *mem_ctx, (*offset) += 4; } - return True; + return true; } -static BOOL smb_raw_query_posix_whoami(void *mem_ctx, +static bool smb_raw_query_posix_whoami(void *mem_ctx, struct torture_context *torture, struct smbcli_state *cli, struct smb_whoami *whoami, @@ -204,7 +205,7 @@ static BOOL smb_raw_query_posix_whoami(void *mem_ctx, "invalid SID count"); torture_assert_int_equal(torture, whoami->num_sid_bytes, 0, "invalid SID byte count"); - return True; + return true; } if (whoami->num_gids != 0) { @@ -232,7 +233,7 @@ static BOOL smb_raw_query_posix_whoami(void *mem_ctx, if (tp.out.data.length == offset) { torture_assert_int_equal(torture, whoami->num_sids, 0, "invalid SID count"); - return True; + return true; } /* All the remaining bytes must be the SID list. */ @@ -251,7 +252,7 @@ static BOOL smb_raw_query_posix_whoami(void *mem_ctx, if (!sid_parse(mem_ctx, torture, &tp.out.data, &offset, &whoami->sid_list[i])) { - return False; + return false; } } @@ -261,10 +262,10 @@ static BOOL smb_raw_query_posix_whoami(void *mem_ctx, torture_assert_int_equal(torture, tp.out.data.length, offset, "trailing garbage bytes"); - return True; + return true; } -BOOL torture_unix_whoami(struct torture_context *torture) +bool torture_unix_whoami(struct torture_context *torture) { struct smbcli_state *cli; struct cli_credentials *anon_credentials; @@ -331,11 +332,11 @@ BOOL torture_unix_whoami(struct torture_context *torture) } talloc_free(mem_ctx); - return True; + return true; fail: talloc_free(mem_ctx); - return False; + return false; } diff --git a/source4/torture/util.c b/source4/torture/util.c index f6287e34d6..0e9dda42fa 100644 --- a/source4/torture/util.c +++ b/source4/torture/util.c @@ -25,24 +25,9 @@ #include "libcli/raw/libcliraw.h" /** - create a temporary directory. -*/ -_PUBLIC_ NTSTATUS torture_temp_dir(struct torture_context *tctx, - const char *prefix, - char **tempdir) -{ - *tempdir = talloc_asprintf(tctx, "%s/%s.XXXXXX", tctx->outputdir, prefix); - - if (mkdtemp(*tempdir) == NULL) - return NT_STATUS_UNSUCCESSFUL; - - return NT_STATUS_OK; -} - -/** check if 2 NTTIMEs are equal. */ -BOOL nt_time_equal(NTTIME *t1, NTTIME *t2) +bool nt_time_equal(NTTIME *t1, NTTIME *t2) { return *t1 == *t2; } @@ -61,7 +46,7 @@ NTSTATUS torture_second_tcon(TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } - result = smbcli_tree_init(session, tmp_ctx, False); + result = smbcli_tree_init(session, tmp_ctx, false); if (result == NULL) { talloc_free(tmp_ctx); return NT_STATUS_NO_MEMORY; diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index d077b3b515..21cdba89eb 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -31,6 +31,7 @@ #include "torture/torture.h" #include "util/dlinklist.h" #include "auth/credentials/credentials.h" +#include "param/param.h" /** @@ -42,9 +43,9 @@ _PUBLIC_ bool torture_setup_dir(struct smbcli_state *cli, const char *dname) if (smbcli_deltree(cli->tree, dname) == -1 || NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, dname))) { printf("Unable to setup %s - %s\n", dname, smbcli_errstr(cli->tree)); - return False; + return false; } - return True; + return true; } /* @@ -286,13 +287,13 @@ bool wire_bad_flags(struct smb_wire_string *str, int flags, struct smbcli_transp { bool server_unicode; int len; - if (!str || !str->s) return True; + if (!str || !str->s) return true; len = strlen(str->s); if (flags & STR_TERMINATE) len++; - server_unicode = (transport->negotiate.capabilities&CAP_UNICODE)?True:False; - if (getenv("CLI_FORCE_ASCII") || !lp_unicode()) { - server_unicode = False; + server_unicode = (transport->negotiate.capabilities&CAP_UNICODE)?true:false; + if (getenv("CLI_FORCE_ASCII") || !lp_unicode(global_loadparm)) { + server_unicode = false; } if ((flags & STR_UNICODE) || server_unicode) { @@ -303,9 +304,9 @@ bool wire_bad_flags(struct smb_wire_string *str, int flags, struct smbcli_transp if (str->private_length != len) { printf("Expected wire_length %d but got %d for '%s'\n", len, str->private_length, str->s); - return True; + return true; } - return False; + return false; } /* @@ -384,7 +385,7 @@ NTSTATUS torture_set_sparse(struct smbcli_tree *tree, int fnum) nt.ntioctl.level = RAW_IOCTL_NTIOCTL; nt.ntioctl.in.function = FSCTL_SET_SPARSE; nt.ntioctl.in.file.fnum = fnum; - nt.ntioctl.in.fsctl = True; + nt.ntioctl.in.fsctl = true; nt.ntioctl.in.filter = 0; nt.ntioctl.in.max_data = 0; nt.ntioctl.in.blob = data_blob(NULL, 0); @@ -475,15 +476,15 @@ _PUBLIC_ bool torture_open_connection_share(TALLOC_CTX *mem_ctx, cmdline_credentials, ev); if (!NT_STATUS_IS_OK(status)) { printf("Failed to open connection - %s\n", nt_errstr(status)); - return False; + return false; } - (*c)->transport->options.use_oplocks = lp_parm_bool(-1, "torture", - "use_oplocks", False); - (*c)->transport->options.use_level2_oplocks = lp_parm_bool(-1, "torture", - "use_level2_oplocks", False); + (*c)->transport->options.use_oplocks = lp_parm_bool(global_loadparm, NULL, "torture", + "use_oplocks", false); + (*c)->transport->options.use_level2_oplocks = lp_parm_bool(global_loadparm, NULL, "torture", + "use_level2_oplocks", false); - return True; + return true; } _PUBLIC_ bool torture_get_conn_index(int conn_index, @@ -494,29 +495,29 @@ _PUBLIC_ bool torture_get_conn_index(int conn_index, int num_unc_names = 0; const char *p; - (*host) = talloc_strdup(mem_ctx, lp_parm_string(-1, "torture", "host")); - (*share) = talloc_strdup(mem_ctx, lp_parm_string(-1, "torture", "share")); + (*host) = talloc_strdup(mem_ctx, lp_parm_string(global_loadparm, NULL, "torture", "host")); + (*share) = talloc_strdup(mem_ctx, lp_parm_string(global_loadparm, NULL, "torture", "share")); - p = lp_parm_string(-1, "torture", "unclist"); + p = lp_parm_string(global_loadparm, NULL, "torture", "unclist"); if (!p) { - return True; + return true; } unc_list = file_lines_load(p, &num_unc_names, NULL); if (!unc_list || num_unc_names <= 0) { DEBUG(0,("Failed to load unc names list from '%s'\n", p)); - return False; + return false; } if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names], mem_ctx, host, share)) { DEBUG(0, ("Failed to parse UNC name %s\n", unc_list[conn_index % num_unc_names])); - return False; + return false; } talloc_free(unc_list); - return True; + return true; } @@ -529,7 +530,7 @@ _PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c, bool ret; if (!torture_get_conn_index(conn_index, ev, &host, &share)) { - return False; + return false; } ret = torture_open_connection_share(NULL, c, host, share, ev); @@ -549,11 +550,11 @@ _PUBLIC_ bool torture_open_connection(struct smbcli_state **c, int conn_index) _PUBLIC_ bool torture_close_connection(struct smbcli_state *c) { - bool ret = True; - if (!c) return True; + bool ret = true; + if (!c) return true; if (NT_STATUS_IS_ERR(smbcli_tdis(c))) { printf("tdis failed (%s)\n", smbcli_errstr(c->tree)); - ret = False; + ret = false; } talloc_free(c); return ret; @@ -576,17 +577,17 @@ _PUBLIC_ bool check_error(const char *location, struct smbcli_state *c, printf(" expected %s or %s (at %s)\n", nt_errstr(NT_STATUS_DOS(eclass, ecode)), nt_errstr(nterr), location); - return False; + return false; } } else { if (!NT_STATUS_EQUAL(nterr, status)) { printf("unexpected error code %s\n", nt_errstr(status)); printf(" expected %s (at %s)\n", nt_errstr(nterr), location); - return False; + return false; } } - return True; + return true; } static struct smbcli_state *current_cli; @@ -608,7 +609,7 @@ double torture_create_procs(struct torture_context *tctx, double start_time_limit = 10 + (torture_nprocs * 1.5); struct timeval tv; - *result = True; + *result = true; synccount = 0; @@ -628,7 +629,7 @@ double torture_create_procs(struct torture_context *tctx, for (i = 0; i < torture_nprocs; i++) { child_status[i] = 0; - child_status_out[i] = True; + child_status_out[i] = true; } tv = timeval_current(); @@ -642,7 +643,7 @@ double torture_create_procs(struct torture_context *tctx, srandom(((int)mypid) ^ ((int)time(NULL))); asprintf(&myname, "CLIENT%d", i); - lp_set_cmdline("netbios name", myname); + lp_set_cmdline(global_loadparm, "netbios name", myname); free(myname); @@ -683,7 +684,7 @@ double torture_create_procs(struct torture_context *tctx, if (synccount != torture_nprocs) { printf("FAILED TO START %d CLIENTS (started %d)\n", torture_nprocs, synccount); - *result = False; + *result = false; return timeval_elapsed(&tv); } @@ -703,7 +704,7 @@ double torture_create_procs(struct torture_context *tctx, int ret; while ((ret=waitpid(0, &status, 0)) == -1 && errno == EINTR) /* noop */ ; if (ret == -1 || WEXITSTATUS(status) != 0) { - *result = False; + *result = false; } } @@ -711,7 +712,7 @@ double torture_create_procs(struct torture_context *tctx, for (i=0;i<torture_nprocs;i++) { if (!child_status_out[i]) { - *result = False; + *result = false; } } return timeval_elapsed(&tv); @@ -829,10 +830,9 @@ static bool wrap_simple_1smb_test(struct torture_context *torture_ctx, } _PUBLIC_ struct torture_test *torture_suite_add_1smb_test( - struct torture_suite *suite, - const char *name, - bool (*run) (struct torture_context *, - struct smbcli_state *)) + struct torture_suite *suite, + const char *name, + bool (*run) (struct torture_context *, struct smbcli_state *)) { struct torture_test *test; struct torture_tcase *tcase; diff --git a/source4/torture/winbind/config.mk b/source4/torture/winbind/config.mk new file mode 100644 index 0000000000..b64b0647fc --- /dev/null +++ b/source4/torture/winbind/config.mk @@ -0,0 +1,15 @@ + +################################# +# Start SUBSYSTEM TORTURE_WINBIND +[MODULE::TORTURE_WINBIND] +SUBSYSTEM = torture +INIT_FUNCTION = torture_winbind_init +PRIVATE_PROTO_HEADER = \ + proto.h +OBJ_FILES = \ + winbind.o \ + struct_based.o +PRIVATE_DEPENDENCIES = \ + LIBWINBIND-CLIENT +# End SUBSYSTEM TORTURE_WINBIND +################################# diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c new file mode 100644 index 0000000000..dd7a1850ab --- /dev/null +++ b/source4/torture/winbind/struct_based.c @@ -0,0 +1,1051 @@ +/* + Unix SMB/CIFS implementation. + SMB torture tester - winbind struct based protocol + Copyright (C) Stefan Metzmacher 2007 + Copyright (C) Michael Adam 2007 + + 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 "pstring.h" +#include "torture/torture.h" +#include "torture/winbind/proto.h" +#include "nsswitch/winbind_client.h" +#include "libcli/security/security.h" +#include "librpc/gen_ndr/netlogon.h" +#include "param/param.h" +#include "auth/pam_errors.h" + +#define DO_STRUCT_REQ_REP_EXT(op,req,rep,expected,strict,warnaction,cmt) do { \ + NSS_STATUS __got, __expected = (expected); \ + __got = winbindd_request_response(op, req, rep); \ + if (__got != __expected) { \ + const char *__cmt = (cmt); \ + if (strict) { \ + torture_result(torture, TORTURE_FAIL, \ + __location__ ": " __STRING(op) \ + " returned %d, expected %d%s%s", \ + __got, __expected, \ + (__cmt) ? ": " : "", \ + (__cmt) ? (__cmt) : ""); \ + return false; \ + } else { \ + torture_warning(torture, \ + __location__ ": " __STRING(op) \ + " returned %d, expected %d%s%s", \ + __got, __expected, \ + (__cmt) ? ": " : "", \ + (__cmt) ? (__cmt) : ""); \ + warnaction; \ + } \ + } \ +} while(0) + +#define DO_STRUCT_REQ_REP(op,req,rep) do { \ + bool __noop = false; \ + DO_STRUCT_REQ_REP_EXT(op,req,rep,NSS_STATUS_SUCCESS,true,__noop=true,NULL); \ +} while (0) + +static bool torture_winbind_struct_interface_version(struct torture_context *torture) +{ + struct winbindd_request req; + struct winbindd_response rep; + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + torture_comment(torture, "Running WINBINDD_INTERFACE_VERSION (struct based)\n"); + + DO_STRUCT_REQ_REP(WINBINDD_INTERFACE_VERSION, &req, &rep); + + torture_assert_int_equal(torture, + rep.data.interface_version, + WINBIND_INTERFACE_VERSION, + "winbind server and client doesn't match"); + + return true; +} + +static bool torture_winbind_struct_ping(struct torture_context *torture) +{ + struct timeval tv = timeval_current(); + int timelimit = torture_setting_int(torture, "timelimit", 5); + uint32_t total = 0; + + torture_comment(torture, + "Running WINBINDD_PING (struct based) for %d seconds\n", + timelimit); + + while (timeval_elapsed(&tv) < timelimit) { + DO_STRUCT_REQ_REP(WINBINDD_PING, NULL, NULL); + total++; + } + + torture_comment(torture, + "%u (%.1f/s) WINBINDD_PING (struct based)\n", + total, total / timeval_elapsed(&tv)); + + return true; +} + + +static char winbind_separator(struct torture_context *torture) +{ + struct winbindd_response rep; + + ZERO_STRUCT(rep); + + DO_STRUCT_REQ_REP(WINBINDD_INFO, NULL, &rep); + + return rep.data.info.winbind_separator; +} + +static bool torture_winbind_struct_info(struct torture_context *torture) +{ + struct winbindd_response rep; + const char *separator; + + ZERO_STRUCT(rep); + + torture_comment(torture, "Running WINBINDD_INFO (struct based)\n"); + + DO_STRUCT_REQ_REP(WINBINDD_INFO, NULL, &rep); + + separator = torture_setting_string(torture, + "winbindd separator", + lp_winbind_separator(global_loadparm)); + torture_assert_int_equal(torture, + rep.data.info.winbind_separator, + *separator, + "winbind separator doesn't match"); + + torture_comment(torture, "Samba Version '%s'\n", + rep.data.info.samba_version); + + return true; +} + +static bool torture_winbind_struct_priv_pipe_dir(struct torture_context *torture) +{ + struct winbindd_response rep; + const char *default_dir; + const char *expected_dir; + const char *got_dir; + + ZERO_STRUCT(rep); + + torture_comment(torture, "Running WINBINDD_PRIV_PIPE_DIR (struct based)\n"); + + DO_STRUCT_REQ_REP(WINBINDD_PRIV_PIPE_DIR, NULL, &rep); + + got_dir = (const char *)rep.extra_data.data; + + torture_assert(torture, got_dir, "NULL WINBINDD_PRIV_PIPE_DIR\n"); + + default_dir = lock_path(torture, global_loadparm, + WINBINDD_PRIV_SOCKET_SUBDIR); + expected_dir = torture_setting_string(torture, + "winbindd private pipe dir", + default_dir); + + torture_assert_str_equal(torture, got_dir, expected_dir, + "WINBINDD_PRIV_PIPE_DIR doesn't match"); + + SAFE_FREE(rep.extra_data.data); + return true; +} + +static bool torture_winbind_struct_netbios_name(struct torture_context *torture) +{ + struct winbindd_response rep; + const char *expected; + + ZERO_STRUCT(rep); + + torture_comment(torture, "Running WINBINDD_NETBIOS_NAME (struct based)\n"); + + DO_STRUCT_REQ_REP(WINBINDD_NETBIOS_NAME, NULL, &rep); + + expected = torture_setting_string(torture, + "winbindd netbios name", + lp_netbios_name(global_loadparm)); + + torture_assert_str_equal(torture, + rep.data.netbios_name, expected, + "winbindd's netbios name doesn't match"); + + return true; +} + +static bool get_winbind_domain(struct torture_context *torture, char **domain) +{ + struct winbindd_response rep; + + ZERO_STRUCT(rep); + + DO_STRUCT_REQ_REP(WINBINDD_DOMAIN_NAME, NULL, &rep); + + *domain = talloc_strdup(torture, rep.data.domain_name); + torture_assert(torture, domain, "talloc error"); + + return true; +} + +static bool torture_winbind_struct_domain_name(struct torture_context *torture) +{ + const char *expected; + char *domain; + + torture_comment(torture, "Running WINBINDD_DOMAIN_NAME (struct based)\n"); + + expected = torture_setting_string(torture, + "winbindd netbios domain", + lp_workgroup(global_loadparm)); + + get_winbind_domain(torture, &domain); + + torture_assert_str_equal(torture, domain, expected, + "winbindd's netbios domain doesn't match"); + + return true; +} + +static bool torture_winbind_struct_check_machacc(struct torture_context *torture) +{ + bool ok; + bool strict = torture_setting_bool(torture, "strict mode", false); + struct winbindd_response rep; + + ZERO_STRUCT(rep); + + torture_comment(torture, "Running WINBINDD_CHECK_MACHACC (struct based)\n"); + + ok = true; + DO_STRUCT_REQ_REP_EXT(WINBINDD_CHECK_MACHACC, NULL, &rep, + NSS_STATUS_SUCCESS, strict, ok = false, + "WINBINDD_CHECK_MACHACC"); + + if (!ok) { + torture_assert(torture, + strlen(rep.data.auth.nt_status_string)>0, + "Failed with empty nt_status_string"); + + torture_warning(torture,"%s:%s:%s:%d\n", + nt_errstr(NT_STATUS(rep.data.auth.nt_status)), + rep.data.auth.nt_status_string, + rep.data.auth.error_string, + rep.data.auth.pam_error); + return true; + } + + torture_assert_ntstatus_ok(torture, + NT_STATUS(rep.data.auth.nt_status), + "WINBINDD_CHECK_MACHACC ok: nt_status"); + + torture_assert_str_equal(torture, + rep.data.auth.nt_status_string, + nt_errstr(NT_STATUS_OK), + "WINBINDD_CHECK_MACHACC ok:nt_status_string"); + + torture_assert_str_equal(torture, + rep.data.auth.error_string, + nt_errstr(NT_STATUS_OK), + "WINBINDD_CHECK_MACHACC ok: error_string"); + + torture_assert_int_equal(torture, + rep.data.auth.pam_error, + nt_status_to_pam(NT_STATUS_OK), + "WINBINDD_CHECK_MACHACC ok: pam_error"); + + return true; +} + +struct torture_trust_domain { + const char *netbios_name; + const char *dns_name; + struct dom_sid *sid; +}; + +static bool get_trusted_domains(struct torture_context *torture, + struct torture_trust_domain **_d) +{ + struct winbindd_request req; + struct winbindd_response rep; + struct torture_trust_domain *d = NULL; + uint32_t dcount = 0; + fstring line; + const char *extra_data; + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep); + + extra_data = (char *)rep.extra_data.data; + torture_assert(torture, extra_data, "NULL trust list"); + + while (next_token(&extra_data, line, "\n", sizeof(fstring))) { + char *p, *lp; + + d = talloc_realloc(torture, d, + struct torture_trust_domain, + dcount + 2); + ZERO_STRUCT(d[dcount+1]); + + lp = line; + p = strchr(lp, '\\'); + torture_assert(torture, p, "missing 1st '\\' in line"); + *p = 0; + d[dcount].netbios_name = talloc_strdup(d, lp); + torture_assert(torture, strlen(d[dcount].netbios_name) > 0, + "empty netbios_name"); + + lp = p+1; + p = strchr(lp, '\\'); + torture_assert(torture, p, "missing 2nd '\\' in line"); + *p = 0; + d[dcount].dns_name = talloc_strdup(d, lp); + /* it's ok to have an empty dns_name */ + + lp = p+1; + d[dcount].sid = dom_sid_parse_talloc(d, lp); + torture_assert(torture, d[dcount].sid, + "failed to parse sid"); + + dcount++; + } + SAFE_FREE(rep.extra_data.data); + + torture_assert(torture, dcount >= 2, + "The list of trusted domain should contain 2 entries"); + + *_d = d; + return true; +} + +static bool torture_winbind_struct_list_trustdom(struct torture_context *torture) +{ + struct winbindd_request req; + struct winbindd_response rep; + char *list1; + char *list2; + bool ok; + struct torture_trust_domain *listd = NULL; + uint32_t i; + + torture_comment(torture, "Running WINBINDD_LIST_TRUSTDOM (struct based)\n"); + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + req.data.list_all_domains = false; + + DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep); + + list1 = (char *)rep.extra_data.data; + torture_assert(torture, list1, "NULL trust list"); + + torture_comment(torture, "%s\n", list1); + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + req.data.list_all_domains = true; + + DO_STRUCT_REQ_REP(WINBINDD_LIST_TRUSTDOM, &req, &rep); + + list2 = (char *)rep.extra_data.data; + torture_assert(torture, list2, "NULL trust list"); + + /* + * The list_all_domains parameter should be ignored + */ + torture_assert_str_equal(torture, list2, list1, "list_all_domains not ignored"); + + SAFE_FREE(list1); + SAFE_FREE(list2); + + ok = get_trusted_domains(torture, &listd); + torture_assert(torture, ok, "failed to get trust list"); + + for (i=0; listd[i].netbios_name; i++) { + if (i == 0) { + struct dom_sid *builtin_sid; + + builtin_sid = dom_sid_parse_talloc(torture, SID_BUILTIN); + + torture_assert_str_equal(torture, + listd[i].netbios_name, + NAME_BUILTIN, + "first domain should be 'BUILTIN'"); + + torture_assert_str_equal(torture, + listd[i].dns_name, + "", + "BUILTIN domain should not have a dns name"); + + ok = dom_sid_equal(builtin_sid, + listd[i].sid); + torture_assert(torture, ok, "BUILTIN domain should have S-1-5-32"); + + continue; + } + + /* + * TODO: verify the content of the 2nd and 3rd (in member server mode) + * domain entries + */ + } + + return true; +} + +static bool torture_winbind_struct_domain_info(struct torture_context *torture) +{ + bool ok; + struct torture_trust_domain *listd = NULL; + uint32_t i; + + torture_comment(torture, "Running WINBINDD_DOMAIN_INFO (struct based)\n"); + + ok = get_trusted_domains(torture, &listd); + torture_assert(torture, ok, "failed to get trust list"); + + for (i=0; listd[i].netbios_name; i++) { + struct winbindd_request req; + struct winbindd_response rep; + struct dom_sid *sid; + char *flagstr = talloc_strdup(torture," "); + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + fstrcpy(req.domain_name, listd[i].netbios_name); + + DO_STRUCT_REQ_REP(WINBINDD_DOMAIN_INFO, &req, &rep); + + torture_assert_str_equal(torture, + rep.data.domain_info.name, + listd[i].netbios_name, + "Netbios domain name doesn't match"); + + torture_assert_str_equal(torture, + rep.data.domain_info.alt_name, + listd[i].dns_name, + "DNS domain name doesn't match"); + + sid = dom_sid_parse_talloc(torture, rep.data.domain_info.sid); + torture_assert(torture, sid, "Failed to parse SID"); + + ok = dom_sid_equal(listd[i].sid, sid); + torture_assert(torture, ok, "SID's doesn't match"); + + if (rep.data.domain_info.primary) { + flagstr = talloc_strdup_append(flagstr, "PR "); + } + + if (rep.data.domain_info.active_directory) { + torture_assert(torture, + strlen(rep.data.domain_info.alt_name)>0, + "Active Directory without DNS name"); + flagstr = talloc_strdup_append(flagstr, "AD "); + } + + if (rep.data.domain_info.native_mode) { + torture_assert(torture, + rep.data.domain_info.active_directory, + "Native-Mode, but no Active Directory"); + flagstr = talloc_strdup_append(flagstr, "NA "); + } + + torture_comment(torture, "DOMAIN '%s' => '%s' [%s]\n", + rep.data.domain_info.name, + rep.data.domain_info.alt_name, + flagstr); + } + + return true; +} + +static bool torture_winbind_struct_getdcname(struct torture_context *torture) +{ + bool ok; + bool strict = torture_setting_bool(torture, "strict mode", false); + struct torture_trust_domain *listd = NULL; + uint32_t i; + + torture_comment(torture, "Running WINBINDD_GETDCNAME (struct based)\n"); + + ok = get_trusted_domains(torture, &listd); + torture_assert(torture, ok, "failed to get trust list"); + + for (i=0; listd[i].netbios_name; i++) { + struct winbindd_request req; + struct winbindd_response rep; + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + fstrcpy(req.domain_name, listd[i].netbios_name); + + ok = true; + DO_STRUCT_REQ_REP_EXT(WINBINDD_GETDCNAME, &req, &rep, + NSS_STATUS_SUCCESS, + (i <2 || strict), ok = false, + talloc_asprintf(torture, "DOMAIN '%s'", + req.domain_name)); + if (!ok) continue; + + /* TODO: check rep.data.dc_name; */ + torture_comment(torture, "DOMAIN '%s' => DCNAME '%s'\n", + req.domain_name, rep.data.dc_name); + } + + return true; +} + +static bool torture_winbind_struct_dsgetdcname(struct torture_context *torture) +{ + bool ok; + bool strict = torture_setting_bool(torture, "strict mode", false); + struct torture_trust_domain *listd = NULL; + uint32_t i; + uint32_t count = 0; + + torture_comment(torture, "Running WINBINDD_DSGETDCNAME (struct based)\n"); + + ok = get_trusted_domains(torture, &listd); + torture_assert(torture, ok, "failed to get trust list"); + + for (i=0; listd[i].netbios_name; i++) { + struct winbindd_request req; + struct winbindd_response rep; + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + if (strlen(listd[i].dns_name) == 0) continue; + + /* + * TODO: remove this and let winbindd give no dns name + * for NT4 domains + */ + if (strcmp(listd[i].dns_name, listd[i].netbios_name) == 0) { + continue; + } + + fstrcpy(req.domain_name, listd[i].dns_name); + + /* TODO: test more flag combinations */ + req.flags = DS_DIRECTORY_SERVICE_REQUIRED; + + ok = true; + DO_STRUCT_REQ_REP_EXT(WINBINDD_DSGETDCNAME, &req, &rep, + NSS_STATUS_SUCCESS, + strict, ok = false, + talloc_asprintf(torture, "DOMAIN '%s'", + req.domain_name)); + if (!ok) continue; + + /* TODO: check rep.data.dc_name; */ + torture_comment(torture, "DOMAIN '%s' => DCNAME '%s'\n", + req.domain_name, rep.data.dc_name); + + count++; + } + + if (count == 0) { + torture_warning(torture, "WINBINDD_DSGETDCNAME" + " was not tested with %d non-AD domains", + i); + } + + if (strict) { + torture_assert(torture, count > 0, + "WiNBINDD_DSGETDCNAME was not tested"); + } + + return true; +} + +static bool get_user_list(struct torture_context *torture, char ***users) +{ + struct winbindd_request req; + struct winbindd_response rep; + char **u = NULL; + uint32_t count; + fstring name; + const char *extra_data; + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + DO_STRUCT_REQ_REP(WINBINDD_LIST_USERS, &req, &rep); + + extra_data = (char *)rep.extra_data.data; + torture_assert(torture, extra_data, "NULL extra data"); + + for(count = 0; + next_token(&extra_data, name, ",", sizeof(fstring)); + count++) + { + u = talloc_realloc(torture, u, char *, count + 2); + u[count+1] = NULL; + u[count] = talloc_strdup(u, name); + } + + SAFE_FREE(rep.extra_data.data); + + *users = u; + return true; +} + +static bool torture_winbind_struct_list_users(struct torture_context *torture) +{ + char **users; + uint32_t count; + bool ok; + + torture_comment(torture, "Running WINBINDD_LIST_USERS (struct based)\n"); + + ok = get_user_list(torture, &users); + torture_assert(torture, ok, "failed to get group list"); + + for (count = 0; users[count]; count++) { } + + torture_comment(torture, "got %d users\n", count); + + return true; +} + +static bool get_group_list(struct torture_context *torture, char ***groups) +{ + struct winbindd_request req; + struct winbindd_response rep; + char **g = NULL; + uint32_t count; + fstring name; + const char *extra_data; + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + DO_STRUCT_REQ_REP(WINBINDD_LIST_GROUPS, &req, &rep); + + extra_data = (char *)rep.extra_data.data; + torture_assert(torture, extra_data, "NULL extra data"); + + for(count = 0; + next_token(&extra_data, name, ",", sizeof(fstring)); + count++) + { + g = talloc_realloc(torture, g, char *, count + 2); + g[count+1] = NULL; + g[count] = talloc_strdup(g, name); + } + + SAFE_FREE(rep.extra_data.data); + + *groups = g; + return true; +} + +static bool torture_winbind_struct_list_groups(struct torture_context *torture) +{ + char **groups; + uint32_t count; + bool ok; + + torture_comment(torture, "Running WINBINDD_LIST_GROUPS (struct based)\n"); + + ok = get_group_list(torture, &groups); + torture_assert(torture, ok, "failed to get group list"); + + for (count = 0; groups[count]; count++) { } + + torture_comment(torture, "got %d groups\n", count); + + return true; +} + +struct torture_domain_sequence { + const char *netbios_name; + uint32_t seq; +}; + +static bool get_sequence_numbers(struct torture_context *torture, + struct torture_domain_sequence **seqs) +{ + struct winbindd_request req; + struct winbindd_response rep; + bool ok; + const char *extra_data; + fstring line; + uint32_t count = 0; + struct torture_domain_sequence *s = NULL; + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep); + + extra_data = (char *)rep.extra_data.data; + torture_assert(torture, extra_data, "NULL sequence list"); + + while (next_token(&extra_data, line, "\n", sizeof(fstring))) { + char *p, *lp; + uint32_t seq; + + s = talloc_realloc(torture, s, struct torture_domain_sequence, + count + 2); + ZERO_STRUCT(s[count+1]); + + lp = line; + p = strchr(lp, ' '); + torture_assert(torture, p, "invalid line format"); + *p = 0; + s[count].netbios_name = talloc_strdup(s, lp); + + lp = p+1; + torture_assert(torture, strncmp(lp, ": ", 2) == 0, + "invalid line format"); + lp += 2; + if (strcmp(lp, "DISCONNECTED") == 0) { + seq = (uint32_t)-1; + } else { + seq = (uint32_t)strtol(lp, &p, 10); + torture_assert(torture, (*p == '\0'), + "invalid line format"); + torture_assert(torture, (seq != (uint32_t)-1), + "sequence number -1 encountered"); + } + s[count].seq = seq; + + count++; + } + SAFE_FREE(rep.extra_data.data); + + torture_assert(torture, count >= 2, "The list of domain sequence " + "numbers should contain 2 entries"); + + *seqs = s; + return true; +} + +static bool torture_winbind_struct_show_sequence(struct torture_context *torture) +{ + bool ok; + uint32_t i; + struct torture_trust_domain *domlist = NULL; + struct torture_domain_sequence *s = NULL; + + torture_comment(torture, "Running WINBINDD_SHOW_SEQUENCE (struct based)\n"); + + ok = get_sequence_numbers(torture, &s); + torture_assert(torture, ok, "failed to get list of sequence numbers"); + + ok = get_trusted_domains(torture, &domlist); + torture_assert(torture, ok, "failed to get trust list"); + + for (i=0; domlist[i].netbios_name; i++) { + struct winbindd_request req; + struct winbindd_response rep; + uint32_t seq; + + torture_assert(torture, s[i].netbios_name, + "more domains recieved in second run"); + torture_assert_str_equal(torture, domlist[i].netbios_name, + s[i].netbios_name, + "inconsistent order of domain lists"); + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + fstrcpy(req.domain_name, domlist[i].netbios_name); + + DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep); + + seq = rep.data.sequence_number; + + if (i == 0) { + torture_assert(torture, (seq != (uint32_t)-1), + "BUILTIN domain disconnected"); + } else if (i == 1) { + torture_assert(torture, (seq != (uint32_t)-1), + "local domain disconnected"); + } + + + if (seq == (uint32_t)-1) { + torture_comment(torture, " * %s : DISCONNECTED\n", + req.domain_name); + } else { + torture_comment(torture, " * %s : %d\n", + req.domain_name, seq); + } + torture_assert(torture, (seq >= s[i].seq), + "illegal sequence number encountered"); + } + + return true; +} + +static bool torture_winbind_struct_setpwent(struct torture_context *torture) +{ + struct winbindd_request req; + struct winbindd_response rep; + + torture_comment(torture, "Running WINBINDD_SETPWENT (struct based)\n"); + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + DO_STRUCT_REQ_REP(WINBINDD_SETPWENT, &req, &rep); + + return true; +} + +static bool torture_winbind_struct_getpwent(struct torture_context *torture) +{ + struct winbindd_request req; + struct winbindd_response rep; + struct winbindd_pw *pwent; + + torture_comment(torture, "Running WINBINDD_GETPWENT (struct based)\n"); + + torture_comment(torture, " - Running WINBINDD_SETPWENT first\n"); + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + DO_STRUCT_REQ_REP(WINBINDD_SETPWENT, &req, &rep); + + torture_comment(torture, " - Running WINBINDD_GETPWENT now\n"); + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + req.data.num_entries = 1; + DO_STRUCT_REQ_REP(WINBINDD_GETPWENT, &req, &rep); + pwent = (struct winbindd_pw *)rep.extra_data.data; + torture_assert(torture, (pwent != NULL), "NULL pwent"); + torture_comment(torture, "name: %s, uid: %d, gid: %d, shell: %s\n", + pwent->pw_name, pwent->pw_uid, pwent->pw_gid, + pwent->pw_shell); + + return true; +} + +static bool torture_winbind_struct_endpwent(struct torture_context *torture) +{ + struct winbindd_request req; + struct winbindd_response rep; + + torture_comment(torture, "Running WINBINDD_ENDPWENT (struct based)\n"); + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + DO_STRUCT_REQ_REP(WINBINDD_ENDPWENT, &req, &rep); + + return true; +} + +/* Copy of parse_domain_user from winbindd_util.c. Parse a string of the + form DOMAIN/user into a domain and a user */ + +static bool parse_domain_user(struct torture_context *torture, + const char *domuser, fstring domain, + fstring user) +{ + char *p = strchr(domuser, winbind_separator(torture)); + char *dom; + + if (!p) { + /* Maybe it was a UPN? */ + if ((p = strchr(domuser, '@')) != NULL) { + fstrcpy(domain, ""); + fstrcpy(user, domuser); + return true; + } + + fstrcpy(user, domuser); + get_winbind_domain(torture, &dom); + fstrcpy(domain, dom); + return true; + } + + fstrcpy(user, p+1); + fstrcpy(domain, domuser); + domain[PTR_DIFF(p, domuser)] = 0; + strupper_m(domain); + + return true; +} + +static bool lookup_name_sid_list(struct torture_context *torture, char **list) +{ + uint32_t count; + + for (count = 0; list[count]; count++) { + struct winbindd_request req; + struct winbindd_response rep; + char *sid; + char *name; + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + parse_domain_user(torture, list[count], req.data.name.dom_name, + req.data.name.name); + + DO_STRUCT_REQ_REP(WINBINDD_LOOKUPNAME, &req, &rep); + + sid = talloc_strdup(torture, rep.data.sid.sid); + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + fstrcpy(req.data.sid, sid); + + DO_STRUCT_REQ_REP(WINBINDD_LOOKUPSID, &req, &rep); + + name = talloc_asprintf(torture, "%s%c%s", + rep.data.name.dom_name, + winbind_separator(torture), + rep.data.name.name); + + torture_assert_casestr_equal(torture, list[count], name, + "LOOKUP_SID after LOOKUP_NAME != id"); + +#if 0 + torture_comment(torture, " %s -> %s -> %s\n", list[count], + sid, name); +#endif + + talloc_free(sid); + talloc_free(name); + } + + return true; +} + +static bool name_is_in_list(const char *name, const char **list) +{ + uint32_t count; + + for (count = 0; list[count]; count++) { + if (strequal(name, list[count])) { + return true; + } + } + return false; +} + +static bool torture_winbind_struct_lookup_name_sid(struct torture_context *torture) +{ + struct winbindd_request req; + struct winbindd_response rep; + const char *invalid_sid = "S-0-0-7"; + char *domain; + const char *invalid_user = "noone"; + char *invalid_name; + bool strict = torture_setting_bool(torture, "strict mode", false); + char **users; + char **groups; + uint32_t count; + bool ok; + + torture_comment(torture, "Running WINBINDD_LOOKUP_NAME_SID (struct based)\n"); + + ok = get_user_list(torture, &users); + torture_assert(torture, ok, "failed to retrieve list of users"); + lookup_name_sid_list(torture, users); + + ok = get_group_list(torture, &groups); + torture_assert(torture, ok, "failed to retrieve list of groups"); + lookup_name_sid_list(torture, groups); + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + fstrcpy(req.data.sid, invalid_sid); + + ok = true; + DO_STRUCT_REQ_REP_EXT(WINBINDD_LOOKUPSID, &req, &rep, + NSS_STATUS_NOTFOUND, + strict, + ok=false, + talloc_asprintf(torture, + "invalid sid %s was resolved", + invalid_sid)); + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + /* try to find an invalid name... */ + + count = 0; + get_winbind_domain(torture, &domain); + do { + count++; + invalid_name = talloc_asprintf(torture, "%s\\%s%u", + domain, + invalid_user, count); + } while(name_is_in_list(invalid_name, (const char **)users) || + name_is_in_list(invalid_name, (const char **)groups)); + + fstrcpy(req.data.name.dom_name, domain); + fstrcpy(req.data.name.name, + talloc_asprintf(torture, "%s%u", invalid_user, + count)); + + ok = true; + DO_STRUCT_REQ_REP_EXT(WINBINDD_LOOKUPNAME, &req, &rep, + NSS_STATUS_NOTFOUND, + strict, + ok=false, + talloc_asprintf(torture, + "invalid name %s was resolved", + invalid_name)); + + talloc_free(users); + talloc_free(groups); + + return true; +} + +struct torture_suite *torture_winbind_struct_init(void) +{ + struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "STRUCT"); + + torture_suite_add_simple_test(suite, "INTERFACE_VERSION", torture_winbind_struct_interface_version); + torture_suite_add_simple_test(suite, "PING", torture_winbind_struct_ping); + torture_suite_add_simple_test(suite, "INFO", torture_winbind_struct_info); + torture_suite_add_simple_test(suite, "PRIV_PIPE_DIR", torture_winbind_struct_priv_pipe_dir); + torture_suite_add_simple_test(suite, "NETBIOS_NAME", torture_winbind_struct_netbios_name); + torture_suite_add_simple_test(suite, "DOMAIN_NAME", torture_winbind_struct_domain_name); + torture_suite_add_simple_test(suite, "CHECK_MACHACC", torture_winbind_struct_check_machacc); + torture_suite_add_simple_test(suite, "LIST_TRUSTDOM", torture_winbind_struct_list_trustdom); + torture_suite_add_simple_test(suite, "DOMAIN_INFO", torture_winbind_struct_domain_info); + torture_suite_add_simple_test(suite, "GETDCNAME", torture_winbind_struct_getdcname); + torture_suite_add_simple_test(suite, "DSGETDCNAME", torture_winbind_struct_dsgetdcname); + torture_suite_add_simple_test(suite, "LIST_USERS", torture_winbind_struct_list_users); + torture_suite_add_simple_test(suite, "LIST_GROUPS", torture_winbind_struct_list_groups); + torture_suite_add_simple_test(suite, "SHOW_SEQUENCE", torture_winbind_struct_show_sequence); + torture_suite_add_simple_test(suite, "SETPWENT", torture_winbind_struct_setpwent); + torture_suite_add_simple_test(suite, "GETPWENT", torture_winbind_struct_getpwent); + torture_suite_add_simple_test(suite, "ENDPWENT", torture_winbind_struct_endpwent); + torture_suite_add_simple_test(suite, "LOOKUP_NAME_SID", torture_winbind_struct_lookup_name_sid); + + suite->description = talloc_strdup(suite, "WINBIND - struct based protocol tests"); + + return suite; +} diff --git a/source4/torture/winbind/winbind.c b/source4/torture/winbind/winbind.c new file mode 100644 index 0000000000..e283602337 --- /dev/null +++ b/source4/torture/winbind/winbind.c @@ -0,0 +1,35 @@ +/* + Unix SMB/CIFS implementation. + SMB torture tester + Copyright (C) Stefan Metzmacher 2007 + + 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 "torture/torture.h" +#include "torture/winbind/proto.h" + +NTSTATUS torture_winbind_init(void) +{ + struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "WINBIND"); + + torture_suite_add_suite(suite, torture_winbind_struct_init()); + + suite->description = talloc_strdup(suite, "WINBIND tests"); + + torture_register_suite(suite); + + return NT_STATUS_OK; +} |