diff options
Diffstat (limited to 'source3/torture')
-rw-r--r-- | source3/torture/cmd_vfs.c | 13 | ||||
-rw-r--r-- | source3/torture/locktest.c | 4 | ||||
-rw-r--r-- | source3/torture/locktest2.c | 2 | ||||
-rw-r--r-- | source3/torture/pdbtest.c | 6 | ||||
-rw-r--r-- | source3/torture/torture.c | 104 |
5 files changed, 76 insertions, 53 deletions
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index 33ced8fa54..cd550a4f48 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -317,11 +317,6 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c if (fsp == NULL) { return NT_STATUS_NO_MEMORY; } - fsp->fsp_name = SMB_STRDUP(argv[1]); - if (fsp->fsp_name == NULL) { - SAFE_FREE(fsp); - return NT_STATUS_NO_MEMORY; - } fsp->fh = SMB_MALLOC_P(struct fd_handle); if (fsp->fh == NULL) { SAFE_FREE(fsp->fsp_name); @@ -333,18 +328,18 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c status = create_synthetic_smb_fname_split(mem_ctx, argv[1], NULL, &smb_fname); if (!NT_STATUS_IS_OK(status)) { - SAFE_FREE(fsp->fsp_name); SAFE_FREE(fsp); return status; } + fsp->fsp_name = smb_fname; + fsp->fh->fd = SMB_VFS_OPEN(vfs->conn, smb_fname, fsp, flags, mode); - TALLOC_FREE(smb_fname); if (fsp->fh->fd == -1) { printf("open: error=%d (%s)\n", errno, strerror(errno)); SAFE_FREE(fsp->fh); - SAFE_FREE(fsp->fsp_name); SAFE_FREE(fsp); + TALLOC_FREE(smb_fname); return NT_STATUS_UNSUCCESSFUL; } @@ -415,7 +410,7 @@ static NTSTATUS cmd_close(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, else printf("close: ok\n"); - SAFE_FREE(vfs->files[fd]->fsp_name); + TALLOC_FREE(vfs->files[fd]->fsp_name); SAFE_FREE(vfs->files[fd]->fh); SAFE_FREE(vfs->files[fd]); vfs->files[fd] = NULL; diff --git a/source3/torture/locktest.c b/source3/torture/locktest.c index 30b84c073d..a90c2e2dfe 100644 --- a/source3/torture/locktest.c +++ b/source3/torture/locktest.c @@ -341,9 +341,9 @@ static bool test_one(struct cli_state *cli[NSERVERS][NCONNECTIONS], case OP_UNLOCK: /* unset a lock */ for (server=0;server<NSERVERS;server++) { - ret[server] = cli_unlock64(cli[server][conn], + ret[server] = NT_STATUS_IS_OK(cli_unlock64(cli[server][conn], fnum[server][conn][f], - start, len); + start, len)); status[server] = cli_nt_error(cli[server][conn]); } if (showall || diff --git a/source3/torture/locktest2.c b/source3/torture/locktest2.c index 93adcb51a6..5c8a2d8019 100644 --- a/source3/torture/locktest2.c +++ b/source3/torture/locktest2.c @@ -132,7 +132,7 @@ static bool try_unlock(struct cli_state *c, int fstype, switch (fstype) { case FSTYPE_SMB: - return cli_unlock(c, fd, start, len); + return NT_STATUS_IS_OK(cli_unlock(c, fd, start, len)); case FSTYPE_NFS: lock.l_type = F_UNLCK; diff --git a/source3/torture/pdbtest.c b/source3/torture/pdbtest.c index ab7edde85d..950177c3ca 100644 --- a/source3/torture/pdbtest.c +++ b/source3/torture/pdbtest.c @@ -288,7 +288,7 @@ int main(int argc, char **argv) pdb_set_homedir(out, "\\\\torture\\home", PDB_SET); pdb_set_logon_script(out, "torture_script.cmd", PDB_SET); - pdb_get_account_policy(AP_PASSWORD_HISTORY, &history); + pdb_get_account_policy(PDB_POLICY_PASSWORD_HISTORY, &history); if (history * PW_HISTORY_ENTRY_LEN < NT_HASH_LEN) { buf = (uint8 *)TALLOC(ctx, NT_HASH_LEN); } else { @@ -311,8 +311,8 @@ int main(int argc, char **argv) } pdb_set_pw_history(out, buf, history, PDB_SET); - pdb_get_account_policy(AP_MAX_PASSWORD_AGE, &expire); - pdb_get_account_policy(AP_MIN_PASSWORD_AGE, &min_age); + pdb_get_account_policy(PDB_POLICY_MAX_PASSWORD_AGE, &expire); + pdb_get_account_policy(PDB_POLICY_MIN_PASSWORD_AGE, &min_age); pdb_set_pass_last_set_time(out, time(NULL), PDB_SET); if (expire == 0 || expire == (uint32)-1) { diff --git a/source3/torture/torture.c b/source3/torture/torture.c index aa7e83bcc8..f9192b12b7 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -492,7 +492,7 @@ static bool rw_torture(struct cli_state *c) correct = False; } - if (!cli_unlock(c, fnum2, n*sizeof(int), sizeof(int))) { + if (!NT_STATUS_IS_OK(cli_unlock(c, fnum2, n*sizeof(int), sizeof(int)))) { printf("unlock failed (%s)\n", cli_errstr(c)); correct = False; } @@ -1429,12 +1429,12 @@ static bool run_locktest2(int dummy) printf("lock at 100 failed (%s)\n", cli_errstr(cli)); } cli_setpid(cli, 2); - if (cli_unlock(cli, fnum1, 100, 4)) { + if (NT_STATUS_IS_OK(cli_unlock(cli, fnum1, 100, 4))) { printf("unlock at 100 succeeded! This is a locking bug\n"); correct = False; } - if (cli_unlock(cli, fnum1, 0, 4)) { + if (NT_STATUS_IS_OK(cli_unlock(cli, fnum1, 0, 4))) { printf("unlock1 succeeded! This is a locking bug\n"); correct = False; } else { @@ -1443,7 +1443,7 @@ static bool run_locktest2(int dummy) NT_STATUS_RANGE_NOT_LOCKED)) return False; } - if (cli_unlock(cli, fnum1, 0, 8)) { + if (NT_STATUS_IS_OK(cli_unlock(cli, fnum1, 0, 8))) { printf("unlock2 succeeded! This is a locking bug\n"); correct = False; } else { @@ -1565,14 +1565,14 @@ static bool run_locktest3(int dummy) for (offset=i=0;i<torture_numops;i++) { NEXT_OFFSET; - if (!cli_unlock(cli1, fnum1, offset-1, 1)) { + if (!NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, offset-1, 1))) { printf("unlock1 %d failed (%s)\n", i, cli_errstr(cli1)); return False; } - if (!cli_unlock(cli2, fnum2, offset-2, 1)) { + if (!NT_STATUS_IS_OK(cli_unlock(cli2, fnum2, offset-2, 1))) { printf("unlock2 %d failed (%s)\n", i, cli_errstr(cli1)); @@ -1703,7 +1703,7 @@ static bool run_locktest4(int dummy) ret = cli_lock(cli1, fnum1, 110, 4, 0, READ_LOCK) && cli_lock(cli1, fnum1, 112, 4, 0, READ_LOCK) && - cli_unlock(cli1, fnum1, 110, 6); + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 110, 6)); EXPECTED(ret, False); printf("the same process %s coalesce read locks\n", ret?"can":"cannot"); @@ -1721,30 +1721,30 @@ static bool run_locktest4(int dummy) ret = cli_lock(cli1, fnum1, 140, 4, 0, READ_LOCK) && cli_lock(cli1, fnum1, 140, 4, 0, READ_LOCK) && - cli_unlock(cli1, fnum1, 140, 4) && - cli_unlock(cli1, fnum1, 140, 4); + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 140, 4)) && + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 140, 4)); EXPECTED(ret, True); printf("this server %s do recursive read locking\n", ret?"does":"doesn't"); ret = cli_lock(cli1, fnum1, 150, 4, 0, WRITE_LOCK) && cli_lock(cli1, fnum1, 150, 4, 0, READ_LOCK) && - cli_unlock(cli1, fnum1, 150, 4) && + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4)) && (cli_read(cli2, fnum2, buf, 150, 4) == 4) && !(cli_write(cli2, fnum2, 0, buf, 150, 4) == 4) && - cli_unlock(cli1, fnum1, 150, 4); + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 150, 4)); EXPECTED(ret, True); printf("this server %s do recursive lock overlays\n", ret?"does":"doesn't"); ret = cli_lock(cli1, fnum1, 160, 4, 0, READ_LOCK) && - cli_unlock(cli1, fnum1, 160, 4) && + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 160, 4)) && (cli_write(cli2, fnum2, 0, buf, 160, 4) == 4) && (cli_read(cli2, fnum2, buf, 160, 4) == 4); EXPECTED(ret, True); printf("the same process %s remove a read lock using write locking\n", ret?"can":"cannot"); ret = cli_lock(cli1, fnum1, 170, 4, 0, WRITE_LOCK) && - cli_unlock(cli1, fnum1, 170, 4) && + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 170, 4)) && (cli_write(cli2, fnum2, 0, buf, 170, 4) == 4) && (cli_read(cli2, fnum2, buf, 170, 4) == 4); EXPECTED(ret, True); @@ -1752,7 +1752,7 @@ static bool run_locktest4(int dummy) ret = cli_lock(cli1, fnum1, 190, 4, 0, WRITE_LOCK) && cli_lock(cli1, fnum1, 190, 4, 0, READ_LOCK) && - cli_unlock(cli1, fnum1, 190, 4) && + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 190, 4)) && !(cli_write(cli2, fnum2, 0, buf, 190, 4) == 4) && (cli_read(cli2, fnum2, buf, 190, 4) == 4); EXPECTED(ret, True); @@ -1861,7 +1861,7 @@ static bool run_locktest5(int dummy) /* Unlock the first process lock, then check this was the WRITE lock that was removed. */ - ret = cli_unlock(cli1, fnum1, 0, 4) && + ret = NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 0, 4)) && cli_lock(cli2, fnum2, 0, 4, 0, READ_LOCK); EXPECTED(ret, True); @@ -1872,15 +1872,15 @@ static bool run_locktest5(int dummy) /* We should have 3 stacked locks here. Ensure we need to do 3 unlocks. */ - ret = cli_unlock(cli1, fnum1, 1, 1) && - cli_unlock(cli1, fnum1, 0, 4) && - cli_unlock(cli1, fnum1, 0, 4); + ret = NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 1, 1)) && + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 0, 4)) && + NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 0, 4)); EXPECTED(ret, True); printf("the same process %s unlock the stack of 4 locks\n", ret?"can":"cannot"); /* Ensure the next unlock fails. */ - ret = cli_unlock(cli1, fnum1, 0, 4); + ret = NT_STATUS_IS_OK(cli_unlock(cli1, fnum1, 0, 4)); EXPECTED(ret, False); printf("the same process %s count the lock stack\n", !ret?"can":"cannot"); @@ -4295,6 +4295,18 @@ static bool run_simple_posix_open_test(int dummy) goto out; } + /* Do a POSIX lock/unlock. */ + if (!NT_STATUS_IS_OK(cli_posix_lock(cli1, fnum1, 0, 100, true, READ_LOCK))) { + printf("POSIX lock failed %s\n", cli_errstr(cli1)); + goto out; + } + + /* Punch a hole in the locked area. */ + if (!NT_STATUS_IS_OK(cli_posix_unlock(cli1, fnum1, 10, 80))) { + printf("POSIX unlock failed %s\n", cli_errstr(cli1)); + goto out; + } + cli_close(cli1, fnum1); /* Open the symlink for read - this should fail. A POSIX @@ -5749,17 +5761,45 @@ static bool run_local_substitute(int dummy) return ok; } +static bool run_local_base64(int dummy) +{ + int i; + bool ret = true; + + for (i=1; i<2000; i++) { + DATA_BLOB blob1, blob2; + char *b64; + + blob1.data = talloc_array(talloc_tos(), uint8_t, i); + blob1.length = i; + generate_random_buffer(blob1.data, blob1.length); + + b64 = base64_encode_data_blob(talloc_tos(), blob1); + if (b64 == NULL) { + d_fprintf(stderr, "base64_encode_data_blob failed " + "for %d bytes\n", i); + ret = false; + } + blob2 = base64_decode_data_blob(b64); + TALLOC_FREE(b64); + + if (data_blob_cmp(&blob1, &blob2)) { + d_fprintf(stderr, "data_blob_cmp failed for %d " + "bytes\n", i); + ret = false; + } + TALLOC_FREE(blob1.data); + data_blob_free(&blob2); + } + return ret; +} + static bool run_local_gencache(int dummy) { char *val; time_t tm; DATA_BLOB blob; - if (!gencache_init()) { - d_printf("%s: gencache_init() failed\n", __location__); - return False; - } - if (!gencache_set("foo", "bar", time(NULL) + 1000)) { d_printf("%s: gencache_set() failed\n", __location__); return False; @@ -5796,15 +5836,13 @@ static bool run_local_gencache(int dummy) } blob = data_blob_string_const_null("bar"); - tm = time(NULL); + tm = time(NULL) + 60; if (!gencache_set_data_blob("foo", &blob, tm)) { d_printf("%s: gencache_set_data_blob() failed\n", __location__); return False; } - data_blob_free(&blob); - if (!gencache_get_data_blob("foo", &blob, NULL)) { d_printf("%s: gencache_get_data_blob() failed\n", __location__); return False; @@ -5835,17 +5873,6 @@ static bool run_local_gencache(int dummy) return False; } - if (!gencache_shutdown()) { - d_printf("%s: gencache_shutdown() failed\n", __location__); - return False; - } - - if (gencache_shutdown()) { - d_printf("%s: second gencache_shutdown() succeeded\n", - __location__); - return False; - } - return True; } @@ -6487,6 +6514,7 @@ static struct { { "STREAMERROR", run_streamerror }, { "LOCAL-SUBSTITUTE", run_local_substitute, 0}, { "LOCAL-GENCACHE", run_local_gencache, 0}, + { "LOCAL-BASE64", run_local_base64, 0}, { "LOCAL-RBTREE", run_local_rbtree, 0}, { "LOCAL-MEMCACHE", run_local_memcache, 0}, { "LOCAL-STREAM-NAME", run_local_stream_name, 0}, |