| 246 | }; |
| 247 | |
| 248 | static bool tf_setup_cache_sentinel(void) { |
| 249 | snprintf(tf_home_sentinel, sizeof(tf_home_sentinel), "/tmp/cbm-test-home-XXXXXX"); |
| 250 | if (!cbm_mkdtemp(tf_home_sentinel)) { |
| 251 | return false; |
| 252 | } |
| 253 | /* Legacy integration fixtures derive DB paths from HOME, while production |
| 254 | * cache_dir() prefers CBM_CACHE_DIR. A private HOME plus no inherited cache |
| 255 | * override keeps both conventions pointed at the same isolated tree. */ |
| 256 | cbm_setenv("HOME", tf_home_sentinel, 1); |
| 257 | cbm_unsetenv("CBM_CACHE_DIR"); |
| 258 | for (size_t i = 0U; i < sizeof(tf_client_home_overrides) / sizeof(tf_client_home_overrides[0]); |
| 259 | i++) { |
| 260 | cbm_unsetenv(tf_client_home_overrides[i]); |
| 261 | } |
| 262 | atexit(tf_cleanup_cache_sentinel); |
| 263 | /* HOME and CBM_CACHE_DIR do not move the daemon rendezvous: its key is a |
| 264 | * constant product hash under the system temp root. Without this, an |
| 265 | * install/uninstall/update test or any endpoint resolved with no explicit |
| 266 | * parent reaches the developer's live daemon. The run always gets a fresh |
| 267 | * private directory; an inherited value is replaced, never reused (the |
| 268 | * rule scripts/test-runtime.sh applies to the shell harness). |
| 269 | * th_secure_runtime_parent_new anchors it where the IPC ancestry check |
| 270 | * accepts it (LocalAppData on Windows). */ |
| 271 | if (!th_secure_runtime_parent_new(tf_runtime_sentinel, sizeof(tf_runtime_sentinel), "run")) { |
| 272 | tf_runtime_sentinel[0] = '\0'; |
| 273 | return false; |
| 274 | } |
| 275 | if (cbm_setenv("CBM_RUNTIME_DIR", tf_runtime_sentinel, 1) != 0) { |
| 276 | return false; |
| 277 | } |
| 278 | #ifdef CBM_ENABLE_TEST_SEAMS |
| 279 | /* Belt and braces: a fixture that later drops the variable gets a loud |
| 280 | * refusal instead of the default rendezvous. */ |
| 281 | cbm_daemon_bootstrap_forbid_default_runtime_for_test(true); |
| 282 | #endif |
| 283 | return true; |
| 284 | } |
| 285 | |
| 286 | static bool tf_path_has_parent(const char *path, const char *parent) { |
| 287 | size_t length = parent ? strlen(parent) : 0; |
no test coverage detected