void ifp_test_req_create(void **state) { struct ifp_req *ireq; struct sbus_request *sr; struct ifp_ctx *ifp_ctx; errno_t ret; assert_true(leak_check_setup()); ifp_ctx = mock_ifp_ctx(global_talloc_context); assert_non_null(ifp_ctx); check_leaks_push(ifp_ctx); sr = mock_sbus_request(ifp_ctx, geteuid()); assert_non_null(sr); check_leaks_push(sr); ret = ifp_req_create(sr, ifp_ctx, &ireq); assert_int_equal(ret, EOK); talloc_free(ireq); assert_true(check_leaks_pop(sr) == true); talloc_free(sr); assert_true(check_leaks_pop(ifp_ctx) == true); talloc_free(ifp_ctx); assert_true(leak_check_teardown()); }
void test_path_escape_unescape(void **state) { char *escaped; char *raw; TALLOC_CTX *mem_ctx; assert_true(leak_check_setup()); mem_ctx = talloc_new(global_talloc_context); escaped = ifp_bus_path_escape(mem_ctx, "noescape"); assert_non_null(escaped); assert_string_equal(escaped, "noescape"); raw = ifp_bus_path_unescape(mem_ctx, escaped); talloc_free(escaped); assert_non_null(raw); assert_string_equal(raw, "noescape"); talloc_free(raw); escaped = ifp_bus_path_escape(mem_ctx, "redhat.com"); assert_non_null(escaped); assert_string_equal(escaped, "redhat_2ecom"); /* dot is 0x2E in ASCII */ raw = ifp_bus_path_unescape(mem_ctx, escaped); talloc_free(escaped); assert_non_null(raw); assert_string_equal(raw, "redhat.com"); talloc_free(raw); escaped = ifp_bus_path_escape(mem_ctx, "path_with_underscore"); assert_non_null(escaped); /* underscore is 0x5F in ascii */ assert_string_equal(escaped, "path_5fwith_5funderscore"); raw = ifp_bus_path_unescape(mem_ctx, escaped); talloc_free(escaped); assert_non_null(raw); assert_string_equal(raw, "path_with_underscore"); talloc_free(raw); /* empty string */ escaped = ifp_bus_path_escape(mem_ctx, ""); assert_non_null(escaped); assert_string_equal(escaped, "_"); raw = ifp_bus_path_unescape(mem_ctx, escaped); talloc_free(escaped); assert_non_null(raw); assert_string_equal(raw, ""); talloc_free(raw); /* negative tests */ escaped = ifp_bus_path_escape(mem_ctx, NULL); assert_null(escaped); raw = ifp_bus_path_unescape(mem_ctx, "wrongpath_"); assert_null(raw); assert_true(leak_check_teardown()); }
void test_switch_user(void **state) { errno_t ret; struct passwd *sssd; TALLOC_CTX *tmp_ctx; struct sss_creds *saved_creds; struct sss_creds *saved_creds2 = NULL; assert_true(leak_check_setup()); tmp_ctx = talloc_new(global_talloc_context); assert_non_null(tmp_ctx); /* Must root as root, real or fake */ assert_int_equal(geteuid(), 0); sssd = getpwnam("sssd"); assert_non_null(sssd); check_leaks_push(tmp_ctx); ret = switch_creds(tmp_ctx, sssd->pw_uid, sssd->pw_gid, 0, NULL, &saved_creds); assert_int_equal(ret, EOK); assert_int_equal(geteuid(), sssd->pw_uid); assert_int_equal(getegid(), sssd->pw_gid); /* Only effective UID is changed.. */ assert_int_equal(getuid(), 0); assert_int_equal(getgid(), 0); assert_non_null(saved_creds); assert_int_equal(saved_creds->uid, 0); assert_int_equal(saved_creds->gid, 0); /* Attempt to restore creds again */ ret = switch_creds(tmp_ctx, sssd->pw_uid, sssd->pw_gid, 0, NULL, &saved_creds2); assert_int_equal(ret, EOK); assert_null(saved_creds2); /* restore root */ ret = restore_creds(saved_creds); assert_int_equal(ret, EOK); assert_int_equal(geteuid(), 0); assert_int_equal(getegid(), 0); assert_int_equal(getuid(), 0); assert_int_equal(getgid(), 0); talloc_free(saved_creds); assert_true(check_leaks_pop(tmp_ctx)); talloc_free(tmp_ctx); assert_true(leak_check_teardown()); }
static int test_ncache_teardown(void **state) { struct ncache_test_ctx *test_ctx; test_ctx = talloc_get_type_abort(*state, struct ncache_test_ctx); test_dom_suite_cleanup(TESTS_PATH, TEST_CONF_DB, TEST_DOM_NAME); assert_true(check_leaks_pop(test_ctx)); talloc_zfree(test_ctx); assert_true(leak_check_teardown()); return 0; }
static int test_sss_idmap_teardown(void **state) { struct test_ctx *test_ctx; test_ctx = talloc_get_type(*state, struct test_ctx); assert_non_null(test_ctx); talloc_free(test_ctx->idmap_ctx); talloc_free(test_ctx->mem_idmap); assert_true(check_leaks_pop(test_ctx) == true); talloc_free(test_ctx); assert_true(leak_check_teardown()); return 0; }
void dyndns_test_teardown(void **state) { talloc_free(dyndns_test_ctx); assert_true(leak_check_teardown()); }