void srv_fssa_cleanup(void)
{
+ talloc_free(fss_global.db_path);
talloc_free(fss_global.mem_ctx);
ZERO_STRUCT(fss_global);
}
return NT_STATUS_NO_MEMORY;
}
+ fss_global.db_path = lock_path(FSS_DB_NAME);
+ if (fss_global.db_path == NULL) {
+ talloc_free(fss_global.mem_ctx);
+ return NT_STATUS_NO_MEMORY;
+ }
+
fss_global.min_vers = FSRVP_RPC_VERSION_1;
fss_global.max_vers = FSRVP_RPC_VERSION_1;
/*
*/
become_root();
status = fss_state_retrieve(fss_global.mem_ctx, &fss_global.sc_sets,
- &fss_global.sc_sets_count);
+ &fss_global.sc_sets_count,
+ fss_global.db_path);
unbecome_root();
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("failed to retrieve fss server state: %s\n",
sc->sc_set->state = FSS_SC_COMMITED;
become_root();
status = fss_state_store(fss_global.mem_ctx, fss_global.sc_sets,
- fss_global.sc_sets_count);
+ fss_global.sc_sets_count,
+ fss_global.db_path);
unbecome_root();
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("failed to store fss server state: %s\n",
sc_set->state = FSS_SC_EXPOSED;
become_root();
status = fss_state_store(fss_global.mem_ctx, fss_global.sc_sets,
- fss_global.sc_sets_count);
+ fss_global.sc_sets_count, fss_global.db_path);
unbecome_root();
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("failed to store fss server state: %s\n",
fss_global.cur_ctx = 0;
become_root();
status = fss_state_store(fss_global.mem_ctx, fss_global.sc_sets,
- fss_global.sc_sets_count);
+ fss_global.sc_sets_count, fss_global.db_path);
unbecome_root();
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("failed to store fss server state: %s\n",
become_root();
status = fss_state_store(fss_global.mem_ctx, fss_global.sc_sets,
- fss_global.sc_sets_count);
+ fss_global.sc_sets_count, fss_global.db_path);
unbecome_root();
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("failed to store fss server state: %s\n",
*/
NTSTATUS fss_state_store(TALLOC_CTX *mem_ctx,
struct fss_sc_set *sc_sets,
- uint32_t sc_sets_count)
+ uint32_t sc_sets_count,
+ const char *db_path)
{
TALLOC_CTX *tmp_ctx;
struct db_context *db;
NTSTATUS status;
int ret;
struct fss_sc_set *sc_set;
- char *db_path;
tmp_ctx = talloc_new(mem_ctx);
if (tmp_ctx == NULL) {
return NT_STATUS_NO_MEMORY;
}
- db_path = lock_path(FSS_DB_NAME);
- if (db_path == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto err_ctx_free;
- }
-
db = db_open(tmp_ctx, db_path, 0, TDB_DEFAULT, O_RDWR | O_CREAT,
0600, DBWRAP_LOCK_ORDER_1);
- talloc_free(db_path);
if (db == NULL) {
DEBUG(0, ("Failed to open fss state TDB\n"));
status = NT_STATUS_ACCESS_DENIED;
NTSTATUS fss_state_retrieve(TALLOC_CTX *mem_ctx,
struct fss_sc_set **sc_sets,
- uint32_t *sc_sets_count)
+ uint32_t *sc_sets_count,
+ const char *db_path)
{
- char *db_path;
struct db_context *db;
NTSTATUS status;
struct fss_traverse_state trv_state;
goto err_out;
}
- db_path = lock_path(FSS_DB_NAME);
- if (db_path == NULL) {
- status = NT_STATUS_NO_MEMORY;
- goto err_ts_free;
- }
-
db = db_open(trv_state.mem_ctx, db_path, 0, TDB_DEFAULT,
O_RDONLY, 0600, DBWRAP_LOCK_ORDER_1);
err = errno;
- talloc_free(db_path);
if ((db == NULL) && (err == ENOENT)) {
DEBUG(4, ("fss state TDB does not exist for retrieval\n"));
status = NT_STATUS_OK;
NTSTATUS status;
struct fss_global fss_global;
struct stat sbuf;
- char *db_path = lock_path(FSS_DB_NAME);
+ char db_dir[] = "fsrvp_torture_XXXXXX";
+ char *db_path = talloc_asprintf(NULL, "%s/%s",
+ mkdtemp(db_dir), FSS_DB_NAME);
memset(&fss_global, 0, sizeof(fss_global));
fss_global.mem_ctx = talloc_new(NULL);
+ fss_global.db_path = db_path;
status = fss_state_store(fss_global.mem_ctx, fss_global.sc_sets,
- fss_global.sc_sets_count);
+ fss_global.sc_sets_count, fss_global.db_path);
torture_assert_ntstatus_ok(tctx, status,
"failed to store empty fss state");
- torture_assert_int_equal(tctx, stat(db_path, &sbuf), 0,
+ torture_assert_int_equal(tctx, stat(fss_global.db_path, &sbuf), 0,
"failed to stat fss state tdb");
talloc_free(fss_global.mem_ctx);
memset(&fss_global, 0, sizeof(fss_global));
fss_global.mem_ctx = talloc_new(NULL);
+ fss_global.db_path = db_path;
status = fss_state_retrieve(fss_global.mem_ctx, &fss_global.sc_sets,
- &fss_global.sc_sets_count);
+ &fss_global.sc_sets_count,
+ fss_global.db_path);
torture_assert_ntstatus_ok(tctx, status,
"failed to retrieve empty fss state");
torture_assert_int_equal(tctx, fss_global.sc_sets_count, 0,
"sc_sets_count set when it should be zero");
talloc_free(fss_global.mem_ctx);
+ unlink(db_path);
+ rmdir(db_dir);
talloc_free(db_path);
return true;
struct fss_sc_set *sc_set;
struct fss_sc *sc;
struct fss_sc_smap *smap;
+ char db_dir[] = "fsrvp_torture_XXXXXX";
+ char *db_path = talloc_asprintf(NULL, "%s/%s",
+ mkdtemp(db_dir), FSS_DB_NAME);
memset(&fss_gs, 0, sizeof(fss_gs));
fss_gs.mem_ctx = talloc_new(NULL);
+ fss_gs.db_path = db_path;
ok = test_fsrvp_state_sc_set(tctx, fss_gs.mem_ctx, &sc_set);
torture_assert(tctx, ok, "failed to create sc set");
sc->smaps_count++;
status = fss_state_store(fss_gs.mem_ctx, fss_gs.sc_sets,
- fss_gs.sc_sets_count);
+ fss_gs.sc_sets_count, fss_gs.db_path);
torture_assert_ntstatus_ok(tctx, status,
"failed to store fss state");
memset(&fss_gr, 0, sizeof(fss_gr));
fss_gr.mem_ctx = talloc_new(NULL);
+ fss_gr.db_path = db_path;
status = fss_state_retrieve(fss_gr.mem_ctx, &fss_gr.sc_sets,
- &fss_gr.sc_sets_count);
+ &fss_gr.sc_sets_count, fss_gr.db_path);
torture_assert_ntstatus_ok(tctx, status,
"failed to retrieve fss state");
talloc_free(fss_gs.mem_ctx);
talloc_free(fss_gr.mem_ctx);
+ unlink(db_path);
+ rmdir(db_dir);
+ talloc_free(db_path);
return true;
}
struct fss_sc_smap *smap_aaa;
struct fss_sc_smap *smap_aba;
struct fss_sc_smap *smap_abb;
+ char db_dir[] = "fsrvp_torture_XXXXXX";
+ char *db_path = talloc_asprintf(NULL, "%s/%s",
+ mkdtemp(db_dir), FSS_DB_NAME);
memset(&fss_gs, 0, sizeof(fss_gs));
fss_gs.mem_ctx = talloc_new(NULL);
+ fss_gs.db_path = db_path;
ok = test_fsrvp_state_sc_set(tctx, fss_gs.mem_ctx, &sc_set_a);
torture_assert(tctx, ok, "failed to create sc set");
sc_ab->smaps_count++;
status = fss_state_store(fss_gs.mem_ctx, fss_gs.sc_sets,
- fss_gs.sc_sets_count);
+ fss_gs.sc_sets_count, fss_gs.db_path);
torture_assert_ntstatus_ok(tctx, status,
"failed to store fss state");
memset(&fss_gr, 0, sizeof(fss_gr));
fss_gr.mem_ctx = talloc_new(NULL);
+ fss_gr.db_path = db_path;
status = fss_state_retrieve(fss_gr.mem_ctx, &fss_gr.sc_sets,
- &fss_gr.sc_sets_count);
+ &fss_gr.sc_sets_count, fss_gr.db_path);
torture_assert_ntstatus_ok(tctx, status,
"failed to retrieve fss state");
talloc_free(fss_gs.mem_ctx);
talloc_free(fss_gr.mem_ctx);
+ unlink(db_path);
+ rmdir(db_dir);
+ talloc_free(db_path);
return true;
}
{
NTSTATUS status;
struct fss_global fss_global;
- char *db_path = lock_path(FSS_DB_NAME);
-
- /* ensure start with an empty db */
- unlink(db_path);
+ char db_dir[] = "fsrvp_torture_XXXXXX";
+ char *db_path = talloc_asprintf(NULL, "%s/%s",
+ mkdtemp(db_dir), FSS_DB_NAME);
memset(&fss_global, 0, sizeof(fss_global));
fss_global.mem_ctx = talloc_new(NULL);
+ fss_global.db_path = db_path;
status = fss_state_retrieve(fss_global.mem_ctx, &fss_global.sc_sets,
- &fss_global.sc_sets_count);
+ &fss_global.sc_sets_count,
+ fss_global.db_path);
torture_assert_ntstatus_ok(tctx, status,
"failed to retrieve fss state");
torture_assert_int_equal(tctx, fss_global.sc_sets_count, 0,
"sc_sets_count set when it should be zero");
talloc_free(fss_global.mem_ctx);
+ unlink(db_path);
+ rmdir(db_dir);
talloc_free(db_path);
return true;
"state_multi",
test_fsrvp_state_multi);
- /* keep this last so that the tdb is cleaned up */
torture_suite_add_simple_test(suite,
"state_none",
test_fsrvp_state_none);