|
@@ -20,46 +20,46 @@ test_checkdir_perms(void *testdata)
|
|
cpd_check_t unix_verify_optsmask;
|
|
cpd_check_t unix_verify_optsmask;
|
|
struct stat st;
|
|
struct stat st;
|
|
|
|
|
|
- /** setup data directory before tests. */
|
|
|
|
|
|
+ /* setup data directory before tests. */
|
|
tor_free(options->DataDirectory);
|
|
tor_free(options->DataDirectory);
|
|
options->DataDirectory = tor_strdup(get_fname(subdir));
|
|
options->DataDirectory = tor_strdup(get_fname(subdir));
|
|
tt_int_op(mkdir(options->DataDirectory, STAT_RWXU), ==, 0);
|
|
tt_int_op(mkdir(options->DataDirectory, STAT_RWXU), ==, 0);
|
|
|
|
|
|
- /** test: create new dir, no flags. */
|
|
|
|
|
|
+ /* test: create new dir, no flags. */
|
|
testdir = get_datadir_fname("checkdir_new_none");
|
|
testdir = get_datadir_fname("checkdir_new_none");
|
|
cpd_chkopts = CPD_CREATE;
|
|
cpd_chkopts = CPD_CREATE;
|
|
- unix_verify_optsmask = STAT_RWXO|STAT_RWXG; /* 0077 */
|
|
|
|
|
|
+ unix_verify_optsmask = 0077;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
|
|
tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
|
|
tor_free(testdir);
|
|
tor_free(testdir);
|
|
|
|
|
|
- /** test: create new dir, CPD_GROUP_OK option set. */
|
|
|
|
|
|
+ /* test: create new dir, CPD_GROUP_OK option set. */
|
|
testdir = get_datadir_fname("checkdir_new_groupok");
|
|
testdir = get_datadir_fname("checkdir_new_groupok");
|
|
cpd_chkopts = CPD_CREATE|CPD_GROUP_OK;
|
|
cpd_chkopts = CPD_CREATE|CPD_GROUP_OK;
|
|
- unix_verify_optsmask = STAT_RWXO|STAT_RWXG; /* 0077 */
|
|
|
|
|
|
+ unix_verify_optsmask = 0077;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
|
|
tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
|
|
tor_free(testdir);
|
|
tor_free(testdir);
|
|
|
|
|
|
|
|
|
|
- /** test: create new dir, CPD_GROUP_READ option set. */
|
|
|
|
|
|
+ /* test: create new dir, CPD_GROUP_READ option set. */
|
|
testdir = get_datadir_fname("checkdir_new_groupread");
|
|
testdir = get_datadir_fname("checkdir_new_groupread");
|
|
cpd_chkopts = CPD_CREATE|CPD_GROUP_READ;
|
|
cpd_chkopts = CPD_CREATE|CPD_GROUP_READ;
|
|
- unix_verify_optsmask = STAT_RWXO|STAT_WGRP; /* 0027 */
|
|
|
|
|
|
+ unix_verify_optsmask = 0027;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
|
|
tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
|
|
tor_free(testdir);
|
|
tor_free(testdir);
|
|
|
|
|
|
|
|
|
|
- /** test: check existing dir created with defaults,
|
|
|
|
|
|
+ /* test: check existing dir created with defaults,
|
|
and verify with CPD_CREATE only. */
|
|
and verify with CPD_CREATE only. */
|
|
testdir = get_datadir_fname("checkdir_exists_none");
|
|
testdir = get_datadir_fname("checkdir_exists_none");
|
|
cpd_chkopts = CPD_CREATE;
|
|
cpd_chkopts = CPD_CREATE;
|
|
- unix_create_opts = STAT_RWXU; /* 0700 */
|
|
|
|
- unix_verify_optsmask = STAT_RWXO|STAT_RWXG; /* 0077 */
|
|
|
|
|
|
+ unix_create_opts = 0700;
|
|
|
|
+ unix_verify_optsmask = 0077;
|
|
tt_int_op(0, ==, mkdir(testdir, unix_create_opts));
|
|
tt_int_op(0, ==, mkdir(testdir, unix_create_opts));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
@@ -67,11 +67,11 @@ test_checkdir_perms(void *testdata)
|
|
tor_free(testdir);
|
|
tor_free(testdir);
|
|
|
|
|
|
|
|
|
|
- /** test: check existing dir created with defaults,
|
|
|
|
|
|
+ /* test: check existing dir created with defaults,
|
|
and verify with CPD_GROUP_OK option set. */
|
|
and verify with CPD_GROUP_OK option set. */
|
|
testdir = get_datadir_fname("checkdir_exists_groupok");
|
|
testdir = get_datadir_fname("checkdir_exists_groupok");
|
|
cpd_chkopts = CPD_CREATE;
|
|
cpd_chkopts = CPD_CREATE;
|
|
- unix_verify_optsmask = STAT_RWXO|STAT_RWXG; /* 0077 */
|
|
|
|
|
|
+ unix_verify_optsmask = 0077;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
cpd_chkopts = CPD_GROUP_OK;
|
|
cpd_chkopts = CPD_GROUP_OK;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
@@ -80,11 +80,11 @@ test_checkdir_perms(void *testdata)
|
|
tor_free(testdir);
|
|
tor_free(testdir);
|
|
|
|
|
|
|
|
|
|
- /** test: check existing dir created with defaults,
|
|
|
|
|
|
+ /* test: check existing dir created with defaults,
|
|
and verify with CPD_GROUP_READ option set. */
|
|
and verify with CPD_GROUP_READ option set. */
|
|
testdir = get_datadir_fname("checkdir_exists_groupread");
|
|
testdir = get_datadir_fname("checkdir_exists_groupread");
|
|
cpd_chkopts = CPD_CREATE;
|
|
cpd_chkopts = CPD_CREATE;
|
|
- unix_verify_optsmask = STAT_RWXO|STAT_WGRP; /* 0027 */
|
|
|
|
|
|
+ unix_verify_optsmask = 0027;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
cpd_chkopts = CPD_GROUP_READ;
|
|
cpd_chkopts = CPD_GROUP_READ;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
@@ -93,11 +93,11 @@ test_checkdir_perms(void *testdata)
|
|
tor_free(testdir);
|
|
tor_free(testdir);
|
|
|
|
|
|
|
|
|
|
- /** test: check existing dir created with CPD_GROUP_READ,
|
|
|
|
|
|
+ /* test: check existing dir created with CPD_GROUP_READ,
|
|
and verify with CPD_GROUP_OK option set. */
|
|
and verify with CPD_GROUP_OK option set. */
|
|
testdir = get_datadir_fname("checkdir_existsread_groupok");
|
|
testdir = get_datadir_fname("checkdir_existsread_groupok");
|
|
cpd_chkopts = CPD_CREATE|CPD_GROUP_READ;
|
|
cpd_chkopts = CPD_CREATE|CPD_GROUP_READ;
|
|
- unix_verify_optsmask = STAT_RWXO|STAT_WGRP; /* 0027 */
|
|
|
|
|
|
+ unix_verify_optsmask = 0027;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
cpd_chkopts = CPD_GROUP_OK;
|
|
cpd_chkopts = CPD_GROUP_OK;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
@@ -106,11 +106,11 @@ test_checkdir_perms(void *testdata)
|
|
tor_free(testdir);
|
|
tor_free(testdir);
|
|
|
|
|
|
|
|
|
|
- /** test: check existing dir created with CPD_GROUP_READ,
|
|
|
|
|
|
+ /* test: check existing dir created with CPD_GROUP_READ,
|
|
and verify with CPD_GROUP_READ option set. */
|
|
and verify with CPD_GROUP_READ option set. */
|
|
testdir = get_datadir_fname("checkdir_existsread_groupread");
|
|
testdir = get_datadir_fname("checkdir_existsread_groupread");
|
|
cpd_chkopts = CPD_CREATE|CPD_GROUP_READ;
|
|
cpd_chkopts = CPD_CREATE|CPD_GROUP_READ;
|
|
- unix_verify_optsmask = STAT_RWXO|STAT_WGRP; /* 0027 */
|
|
|
|
|
|
+ unix_verify_optsmask = 0027;
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, check_private_dir(testdir, cpd_chkopts, NULL));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
tt_int_op(0, ==, stat(testdir, &st));
|
|
tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
|
|
tt_int_op(0, ==, (st.st_mode & unix_verify_optsmask));
|