NTSTATUS torture_rpc_connection(struct dcerpc_pipe **p,
const char *pipe_name,
const char *pipe_uuid,
- uint32 pipe_version)
+ uint32_t pipe_version)
{
NTSTATUS status;
char *binding = lp_parm_string(-1, "torture", "binding");
/* check if the server produced the expected error code */
static BOOL check_error(int line, struct cli_state *c,
- uint8 eclass, uint32 ecode, NTSTATUS nterr)
+ uint8_t eclass, uint32_t ecode, NTSTATUS nterr)
{
if (cli_is_dos_error(c->tree)) {
- uint8 class;
- uint32 num;
+ uint8_t class;
+ uint32_t num;
/* Check DOS error */
}
-static BOOL wait_lock(struct cli_state *c, int fnum, uint32 offset, uint32 len)
+static BOOL wait_lock(struct cli_state *c, int fnum, uint32_t offset, uint32_t len)
{
while (NT_STATUS_IS_ERR(cli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK))) {
if (!check_error(__LINE__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False;
BOOL correct = True;
srandom(1);
- for (i = 0; i < sizeof(buf); i += sizeof(uint32))
+ for (i = 0; i < sizeof(buf); i += sizeof(uint32_t))
{
SIVAL(buf, i, sys_random());
}
struct cli_state *cli;
const char *fname = "\\tcontest.tmp";
int fnum1;
- uint16 cnum1, cnum2, cnum3;
- uint16 vuid1, vuid2;
+ uint16_t cnum1, cnum2, cnum3;
+ uint16_t vuid1, vuid2;
char buf[4];
BOOL ret = True;
struct cli_tree *tree1;
struct cli_state *cli1, *cli2;
const char *fname = "\\lockt3.lck";
int fnum1, fnum2, i;
- uint32 offset;
+ uint32_t offset;
BOOL correct = True;
-#define NEXT_OFFSET offset += (~(uint32)0) / torture_numops
+#define NEXT_OFFSET offset += (~(uint32_t)0) / torture_numops
if (!torture_open_connection(&cli1) || !torture_open_connection(&cli2)) {
return False;
struct cli_state *cli1;
const char *fname = "\\lockt7.lck";
int fnum1;
+ int fnum2;
+ size_t size;
char buf[200];
BOOL correct = False;
goto fail;
}
- cli_unlock(cli1->tree, fnum1, 130, 0);
+ printf("Testing truncate of locked file.\n");
+
+ fnum2 = cli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE);
+
+ if (fnum2 == -1) {
+ printf("Unable to truncate locked file.\n");
+ correct = False;
+ goto fail;
+ } else {
+ printf("Truncated locked file.\n");
+ }
+
+ if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, NULL, &size, NULL))) {
+ printf("getatr failed (%s)\n", cli_errstr(cli1->tree));
+ correct = False;
+ goto fail;
+ }
+
+ if (size != 0) {
+ printf("Unable to truncate locked file. Size was %u\n", size);
+ correct = False;
+ goto fail;
+ }
+
+ cli1->session->pid = 1;
+
+ cli_unlock(cli1->tree, fnum1, 130, 4);
correct = True;
fail:
cli_close(cli1->tree, fnum1);
+ cli_close(cli1->tree, fnum2);
cli_unlink(cli1->tree, fname);
torture_close_connection(cli1);
time_t c_time, a_time, m_time, w_time, m_time2;
BOOL correct = True;
- uint16 orig_vuid;
+ uint16_t orig_vuid;
NTSTATUS result;
printf("starting vuid test\n");
}
printf("non-io open test #7 passed.\n");
+
error_test70:
+
+ printf("TEST #8 testing one normal open, followed by lock, followed by open with truncate\n");
+
+ cli_unlink(cli1->tree, fname);
+
+ fnum1 = cli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE);
+ if (fnum1 == -1) {
+ printf("(8) open (1) of %s failed (%s)\n", fname, cli_errstr(cli1->tree));
+ return False;
+ }
+
+ /* write 20 bytes. */
+
+ memset(buf, '\0', 20);
+
+ if (cli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) {
+ printf("(8) write failed (%s)\n", cli_errstr(cli1->tree));
+ correct = False;
+ }
+
+ /* Ensure size == 20. */
+ if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
+ printf("(8) getatr (1) failed (%s)\n", cli_errstr(cli1->tree));
+ CHECK_MAX_FAILURES(error_test80);
+ return False;
+ }
+
+ if (fsize != 20) {
+ printf("(8) file size != 20\n");
+ CHECK_MAX_FAILURES(error_test80);
+ return False;
+ }
+
+ /* Get an exclusive lock on the open file. */
+ if (NT_STATUS_IS_ERR(cli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK))) {
+ printf("(8) lock1 failed (%s)\n", cli_errstr(cli1->tree));
+ CHECK_MAX_FAILURES(error_test80);
+ return False;
+ }
+
+ fnum2 = cli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE);
+ if (fnum1 == -1) {
+ printf("(8) open (2) of %s with truncate failed (%s)\n", fname, cli_errstr(cli1->tree));
+ return False;
+ }
+
+ /* Ensure size == 0. */
+ if (NT_STATUS_IS_ERR(cli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) {
+ printf("(8) getatr (2) failed (%s)\n", cli_errstr(cli1->tree));
+ CHECK_MAX_FAILURES(error_test80);
+ return False;
+ }
+
+ if (fsize != 0) {
+ printf("(8) file size != 0\n");
+ CHECK_MAX_FAILURES(error_test80);
+ return False;
+ }
+
+ if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum1))) {
+ printf("(8) close1 failed (%s)\n", cli_errstr(cli1->tree));
+ return False;
+ }
+
+ if (NT_STATUS_IS_ERR(cli_close(cli1->tree, fnum2))) {
+ printf("(8) close1 failed (%s)\n", cli_errstr(cli1->tree));
+ return False;
+ }
+
+error_test80:
+
+ printf("open test #8 passed.\n");
+
cli_unlink(cli1->tree, fname);
if (!torture_close_connection(cli1)) {
}
-static uint32 open_attrs_table[] = {
+static uint32_t open_attrs_table[] = {
FILE_ATTRIBUTE_NORMAL,
FILE_ATTRIBUTE_ARCHIVE,
FILE_ATTRIBUTE_READONLY,
struct trunc_open_results {
unsigned int num;
- uint32 init_attr;
- uint32 trunc_attr;
- uint32 result_attr;
+ uint32_t init_attr;
+ uint32_t trunc_attr;
+ uint32_t result_attr;
};
static struct trunc_open_results attr_results[] = {
const char *fname = "\\openattr.file";
int fnum1;
BOOL correct = True;
- uint16 attr;
+ uint16_t attr;
unsigned int i, j, k, l;
int failures = 0;
return False;
}
- for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32); i++) {
+ for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32_t); i++) {
cli_setatr(cli1->tree, fname, 0, 0);
cli_unlink(cli1->tree, fname);
fnum1 = cli_nt_create_full(cli1->tree, fname, 0, SA_RIGHT_FILE_WRITE_DATA, open_attrs_table[i],
BOOL torture_ioctl_test(int dummy)
{
struct cli_state *cli;
- uint16 device, function;
+ uint16_t device, function;
int fnum;
const char *fname = "\\ioctl.dat";
NTSTATUS status;
{"RPC-MGMT", torture_rpc_mgmt, 0},
{"RPC-SCANNER", torture_rpc_scanner, 0},
{"RPC-AUTOIDL", torture_rpc_autoidl, 0},
+/* {"NTLMSSP-SELFCHECK", torture_ntlmssp_self_check, 0},*/
{NULL, NULL, 0}};
*/
static void parse_user(const char *user)
{
- char *username, *password, *p;
+ char *username, *password = NULL, *p;
username = strdup(user);
p = strchr_m(username,'%');
}
lp_set_cmdline("torture:username", username);
- lp_set_cmdline("torture:password", password);
-}
+ if (password) {
+ lp_set_cmdline("torture:password", password);
+ }
+
+ if (!lp_parm_string(-1,"torture","password")) {
+ password = getpass("password:");
+
+ lp_set_cmdline("torture:password", password);
+ }
+}
static void usage(void)
{
}
}
+ if (!lp_parm_string(-1,"torture","password")) {
+ lp_set_cmdline("torture:password", "");
+ }
+
if (argc == optind) {
printf("You must specify a test to run, or 'ALL'\n");
} else {