diff --git a/src/lib-config/write.c b/src/lib-config/write.c index 5dbbd1ed..b7c6edb5 100644 --- a/src/lib-config/write.c +++ b/src/lib-config/write.c @@ -305,6 +305,9 @@ int config_write(CONFIG_REC *rec, const char *fname, int create_mode) const char *base_name; char *tmp_name = NULL; char *dest_name = NULL; +#if !defined(_POSIX_VERSION) || _POSIX_VERSION < 200809L + char resolved_path[PATH_MAX] = { 0 }; +#endif g_return_val_if_fail(rec != NULL, -1); g_return_val_if_fail(fname != NULL || rec->fname != NULL, -1); @@ -313,16 +316,15 @@ int config_write(CONFIG_REC *rec, const char *fname, int create_mode) base_name = fname != NULL ? fname : rec->fname; /* expand all symlinks; else we may replace a symlink with a regular file */ - dest_name = realpath(base_name, NULL); - - if (errno == EINVAL) { - /* variable path length not supported by glibc < 2.3, Solaris < 11 */ - char resolved_path[PATH_MAX] = { 0 }; - errno = 0; - if ((dest_name = realpath(base_name, resolved_path)) != NULL) { - dest_name = g_strdup(dest_name); - } +#if !defined(_POSIX_VERSION) || _POSIX_VERSION < 200809L + /* variable path length not supported by glibc < 2.3, Solaris < 11 */ + errno = 0; + if ((dest_name = realpath(base_name, resolved_path)) != NULL) { + dest_name = g_strdup(dest_name); } +#else + dest_name = realpath(base_name, NULL); +#endif if (dest_name == NULL) { if (errno == ENOENT) {