diff options
Diffstat (limited to 'cpp')
-rwxr-xr-x | cpp/src/iceserviceinstall/ServiceInstaller.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cpp/src/iceserviceinstall/ServiceInstaller.cpp b/cpp/src/iceserviceinstall/ServiceInstaller.cpp index fc055fe1efc..62abe1c45b9 100755 --- a/cpp/src/iceserviceinstall/ServiceInstaller.cpp +++ b/cpp/src/iceserviceinstall/ServiceInstaller.cpp @@ -30,6 +30,9 @@ using namespace std; using namespace Ice; +namespace +{ + // // Replace / by \ // @@ -47,6 +50,35 @@ fixDirSeparator(const string& path) return result; } +bool +isAbsolutePath(const string& path) +{ + size_t i = 0; + size_t size = path.size(); + + // Skip whitespace + while(i < size && isspace(path[i])) + { + ++i; + } + + // We need at least 3 non whitespace character to have + // and absolute path + if(i + 3 > size) + { + return false; + } + + // Check for X:\ path + if((path[i] >= 'A' && path[i] <= 'Z') || (path[i] >= 'a' && path[i] <= 'z')) + { + return path[i + 1] == ':' && path[i + 2] == '\\'; + } + + // Check for UNC path + return path[i] == '\\' && path[i + 1] == '\\'; +} +} IceServiceInstaller::IceServiceInstaller(int serviceType, const string& configFile, const CommunicatorPtr& communicator) : @@ -178,6 +210,11 @@ IceServiceInstaller::install(const PropertiesPtr& properties) { throw "IceGrid.Registry.Data must be set in " + _configFile; } + if(!isAbsolutePath(registryDataDir)) + { + throw "'" + registryDataDir + "' is a relative path; IceGrid.Registry.Data must be an absolute path"; + } + if(!mkdir(registryDataDir)) { grantPermissions(registryDataDir, SE_FILE_OBJECT, true, true); @@ -190,6 +227,11 @@ IceServiceInstaller::install(const PropertiesPtr& properties) { throw "IceGrid.Node.Data must be set in " + _configFile; } + if(!isAbsolutePath(nodeDataDir)) + { + throw "'" + nodeDataDir + "' is a relative path; IceGrid.Node.Data must be an absolute path"; + } + if(!mkdir(nodeDataDir)) { grantPermissions(nodeDataDir, SE_FILE_OBJECT, true, true); |