From 13498d8ec8a884ca2ca5e6973485401da0515e1d Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 7 Feb 2018 13:35:18 +0200 Subject: [PATCH] MXS-1655 Allow symbolic links to files in config directory --- server/core/config.cc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/server/core/config.cc b/server/core/config.cc index 5c51d48c4..073adaa5e 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -609,6 +609,39 @@ int config_cb(const char* fpath, const struct stat *sb, int typeflag, struct FTW { int rval = 0; + if (typeflag == FTW_SL) // A symbolic link; let's see what it points to. + { + struct stat sb; + + if (stat(fpath, &sb) == 0) + { + int file_type = (sb.st_mode & S_IFMT); + + switch (file_type) + { + case S_IFREG: + // Points to a file; we'll handle that regardless of where the file resides. + typeflag = FTW_F; + break; + + case S_IFDIR: + // Points to a directory; we'll ignore that. + MXS_WARNING("Symbolic link %s in configuration directory points to a " + "directory; it will be ignored.", fpath); + break; + + default: + // Points to something else; we'll silently ignore. + ; + } + } + else + { + MXS_WARNING("Could not get information about the symbolic link %s; " + "it will be ignored.", fpath); + } + } + if (typeflag == FTW_F) // We are only interested in files, { const char* filename = fpath + ftwbuf->base;