| 173 | } |
| 174 | |
| 175 | const char *get_state_dir(void) |
| 176 | { |
| 177 | static char path[PATH_MAX] = {'\0'}; |
| 178 | char *state_dir; |
| 179 | int res; |
| 180 | |
| 181 | if (path[0] == '\0') { |
| 182 | if (icmap_get_string("system.state_dir", &state_dir) == CS_OK) { |
| 183 | res = snprintf(path, PATH_MAX, "%s", state_dir); |
| 184 | free(state_dir); |
| 185 | } else if ((state_dir = getenv("STATE_DIRECTORY")) != NULL) { |
| 186 | /* |
| 187 | * systemd allows multiple directory names that are |
| 188 | * passed to env variable separated by colon. Support for this feature |
| 189 | * is deliberately not implemented because corosync always |
| 190 | * uses just one state directory and it is unclear what behavior should |
| 191 | * be taken for multiple ones. If reasonable need for |
| 192 | * supporting multiple directories appear, it must be implemented also |
| 193 | * for cmap. |
| 194 | */ |
| 195 | res = snprintf(path, PATH_MAX, "%s", state_dir); |
| 196 | } else { |
| 197 | res = snprintf(path, PATH_MAX, "%s/%s", LOCALSTATEDIR, "lib/corosync"); |
| 198 | } |
| 199 | |
| 200 | assert(res < PATH_MAX); |
| 201 | } |
| 202 | |
| 203 | return (path); |
| 204 | } |
| 205 | |
| 206 | static int safe_strcat(char *dst, size_t dst_len, const char *src) |
| 207 | { |
no test coverage detected