From 9e13892e280cf848abf022430f2cbc1f8e214298 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Mon, 13 May 2019 15:15:46 +0200 Subject: [PATCH] fix realpath on old solaris POSIX.1-2001 did not implement realpath(..., NULL) yet. Fixes #1042 --- src/lib-config/write.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lib-config/write.c b/src/lib-config/write.c index b8ef6156..5dbbd1ed 100644 --- a/src/lib-config/write.c +++ b/src/lib-config/write.c @@ -315,6 +315,15 @@ int config_write(CONFIG_REC *rec, const char *fname, int create_mode) /* 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 (dest_name == NULL) { if (errno == ENOENT) { dest_name = g_strdup(base_name);