]> granicus.if.org Git - icinga2/commitdiff
Fix absolute include paths for windows 5187/head
authorJean Flach <jean-marcel.flach@icinga.com>
Mon, 24 Apr 2017 13:39:21 +0000 (15:39 +0200)
committerJean Flach <jean-marcel.flach@icinga.com>
Mon, 24 Apr 2017 13:39:21 +0000 (15:39 +0200)
fixes #5168

lib/config/configcompiler.cpp
lib/config/configcompiler.hpp

index fa5c90d37833a9bf512f868f4009c9afc23bc8f2..6b5f3a3caecb17847dad58f029cfe00fa4ddeba3 100644 (file)
 #include "base/exception.hpp"
 #include <fstream>
 
+#ifdef _WIN32
+#include "Shlwapi.h"
+#endif /* _WIN32 */
+
 using namespace icinga;
 
 std::vector<String> ConfigCompiler::m_IncludeSearchDirs;
@@ -135,7 +139,7 @@ Expression *ConfigCompiler::HandleInclude(const String& relativeBase, const Stri
 {
        String upath;
 
-       if (search || (path.GetLength() > 0 && path[0] == '/'))
+       if (search || (IsAbsolutePath(path)))
                upath = path;
        else
                upath = relativeBase + "/" + path;
@@ -179,7 +183,7 @@ Expression *ConfigCompiler::HandleIncludeRecursive(const String& relativeBase, c
 {
        String ppath;
 
-       if (path.GetLength() > 0 && path[0] == '/')
+       if (IsAbsolutePath(path))
                ppath = path;
        else
                ppath = relativeBase + "/" + path;
@@ -198,7 +202,7 @@ void ConfigCompiler::HandleIncludeZone(const String& relativeBase, const String&
 
        String ppath;
 
-       if (path.GetLength() > 0 && path[0] == '/')
+       if (IsAbsolutePath(path))
                ppath = path;
        else
                ppath = relativeBase + "/" + path;
@@ -223,7 +227,7 @@ Expression *ConfigCompiler::HandleIncludeZones(const String& relativeBase, const
        String ppath;
        String newRelativeBase = relativeBase;
 
-       if (path.GetLength() > 0 && path[0] == '/')
+       if (IsAbsolutePath(path))
                ppath = path;
        else {
                ppath = relativeBase + "/" + path;
@@ -350,4 +354,3 @@ bool ConfigCompiler::HasZoneConfigAuthority(const String& zoneName)
 
        return !empty;
 }
-
index d8812dd1c347a50bc85106cd78a1a5031d9f87e6..472fa2330b0fa1250394bd0686293bb4188e0ef0 100644 (file)
@@ -127,6 +127,14 @@ public:
 
        static bool HasZoneConfigAuthority(const String& zoneName);
 
+       static inline bool IsAbsolutePath(const String& path) {
+#ifndef _WIN32
+               return (path.GetLength() > 0 && path[0] == '/');
+#else
+               return !PathIsRelative(path.CStr());
+#endif /* _WIN32 */
+       }
+
 private:
        boost::promise<boost::shared_ptr<Expression> > m_Promise;