Describe what the target actually IS, so a refusal is triageable. * * The config editors collapse nine distinct fail-closed conditions into a * single -1: unsupported structure, an inline comment on a field line, a * non-single-link file, unsafe metadata, lock contention, I/O. `agent=X op=Y * path=Z` alone cannot separate them, and four such failures currently live in * discussion #1560 with
| 8455 | * most of the space — it says the refusal is structural, not a permission or |
| 8456 | * missing-file problem. */ |
| 8457 | static void describe_agent_config_target(const char *path, char *out, size_t out_size) { |
| 8458 | if (!out || out_size == 0) { |
| 8459 | return; |
| 8460 | } |
| 8461 | out[0] = '\0'; |
| 8462 | if (!path || !path[0]) { |
| 8463 | return; |
| 8464 | } |
| 8465 | cbm_path_info_t info; |
| 8466 | if (cbm_path_info_utf8(path, &info) != 0) { |
| 8467 | (void)snprintf(out, out_size, " (target: does not exist or cannot be inspected)"); |
| 8468 | return; |
| 8469 | } |
| 8470 | const char *kind = info.is_symlink ? "symlink" |
| 8471 | : info.is_directory ? "directory" |
| 8472 | : info.is_regular ? "regular file" |
| 8473 | : "special file"; |
| 8474 | /* A refused symlink names the rule that refused it (#1954): the user |
| 8475 | * then knows whether to fix ownership, the target, or the parent. */ |
| 8476 | char refusal[160]; |
| 8477 | if (info.is_symlink && cbm_config_edit_path_refusal(path, refusal, sizeof(refusal))) { |
| 8478 | (void)snprintf(out, out_size, " (target: symlink, %lld bytes; not followed: %s)", |
| 8479 | (long long)info.size, refusal); |
| 8480 | return; |
| 8481 | } |
| 8482 | (void)snprintf(out, out_size, " (target: %s, %lld bytes)", kind, (long long)info.size); |
| 8483 | } |
| 8484 | |
| 8485 | static void record_agent_config_error_with_reason(bool uninstalling, const char *agent, |
| 8486 | const char *operation, const char *path, |
no test coverage detected