| 8507 | } |
| 8508 | |
| 8509 | static bool prepare_config_parent(const char *path) { |
| 8510 | if (!path || !path[0]) { |
| 8511 | return false; |
| 8512 | } |
| 8513 | char parent[CLI_BUF_1K]; |
| 8514 | int written = snprintf(parent, sizeof(parent), "%s", path); |
| 8515 | if (written < 0 || (size_t)written >= sizeof(parent)) { |
| 8516 | return false; |
| 8517 | } |
| 8518 | char *slash = strrchr(parent, '/'); |
| 8519 | char *backslash = strrchr(parent, '\\'); |
| 8520 | if (backslash && (!slash || backslash > slash)) { |
| 8521 | slash = backslash; |
| 8522 | } |
| 8523 | if (!slash || slash == parent) { |
| 8524 | return slash != NULL; |
| 8525 | } |
| 8526 | *slash = '\0'; |
| 8527 | /* Agent roots live under HOME / XDG / the client's own config-dir |
| 8528 | * variable, so a symlink the user owns on the way is followed (#1722). */ |
| 8529 | return cbm_mkdir_p_ex(parent, CLI_OCTAL_PERM, CBM_MKDIR_FOLLOW_OWNED); |
| 8530 | } |
| 8531 | |
| 8532 | typedef struct { |
| 8533 | const char *label; |
no test coverage detected