From: <ale...@us...> - 2014-01-31 14:43:28
|
Revision: 59094 http://sourceforge.net/p/firebird/code/59094 Author: alexpeshkoff Date: 2014-01-31 14:43:25 +0000 (Fri, 31 Jan 2014) Log Message: ----------- Misc enhancements in .conf parser and *.conf.in files Modified Paths: -------------- firebird/trunk/builds/install/misc/databases.conf.in firebird/trunk/builds/install/misc/firebird.conf.in firebird/trunk/src/common/config/config_file.cpp firebird/trunk/src/common/config/config_file.h firebird/trunk/src/common/os/path_utils.h firebird/trunk/src/common/os/posix/path_utils.cpp firebird/trunk/src/common/os/win32/path_utils.cpp Modified: firebird/trunk/builds/install/misc/databases.conf.in =================================================================== --- firebird/trunk/builds/install/misc/databases.conf.in 2014-01-31 00:55:25 UTC (rev 59093) +++ firebird/trunk/builds/install/misc/databases.conf.in 2014-01-31 14:43:25 UTC (rev 59094) @@ -17,14 +17,14 @@ # # Example Database: # -employee.fdb = $(dir_sampledb)/employee.fdb -employee = $(dir_sampledb)/employee.fdb +employee.fdb = $(dir_sampleDb)/employee.fdb +employee = $(dir_sampleDb)/employee.fdb # # Master security database specific setup. # Do not remove it until you understand well what are you doing! # -security.db = $(root)/security3.fdb +security.db = $(dir_secDb)/security3.fdb { RemoteAccess = false } Modified: firebird/trunk/builds/install/misc/firebird.conf.in =================================================================== --- firebird/trunk/builds/install/misc/firebird.conf.in 2014-01-31 00:55:25 UTC (rev 59093) +++ firebird/trunk/builds/install/misc/firebird.conf.in 2014-01-31 14:43:25 UTC (rev 59094) @@ -58,18 +58,20 @@ # ------------------ # There is a number of predefined macro commands, that can be used in config # files where directory name is needed. They are available using $(name) syntax. -# The complete list of the as follows: +# The complete list of them as follows: # root - root directory of firebird instance # install - directory where firebird is installed # this - directory where current configuration file is located # dir_conf - directory where firebird.conf and databases.conf are located -# dir_secdb - directory where default security database is located +# dir_secDb - directory where default security database is located # dir_plugins - directory where plugins are located # dir_udf - directory where UDFs are located by default # dir_sample - directory where samples are located -# dir_sampledb - directory where sample DB (employee.fdb) is located +# dir_sampleDb - directory where sample DB (employee.fdb) is located # dir_intl - directory where international modules are located # dir_msg - directory where messages file (firebird.msg) is located +# Like the rest of config internals macros are case-insensitive. +# Capital letters here are used only for better human readability. # # # Includes @@ -121,6 +123,24 @@ # ---------------------------- +# Ability to access databases remotely +# +# RemoteAccess may be true or false (1/0, Yes/No) - it's boolean value. +# By default RemoteAccess to all databases except security DB is enabled. +# If you plan to use more than one dedicated security database it's +# recommended to disable remote access to them in databases.conf. +# However (as an additional method to have secure enhanced firebird +# installation) one can disable remote access globally and re-enable +# in databases.conf only for specific databases. +# +# Per-database configurable. +# +# Type: boolean +# +#RemoteAccess = true + + +# ---------------------------- # External File Paths/Directories # # ExternalFileAccess may be None, Full or Restrict. If you choose @@ -727,7 +747,7 @@ # # Type: string (pathname) # -#SecurityDatabase = $(root)/security3.fdb +#SecurityDatabase = $(dir_secDb)/security3.fdb # ============================== Modified: firebird/trunk/src/common/config/config_file.cpp =================================================================== --- firebird/trunk/src/common/config/config_file.cpp 2014-01-31 00:55:25 UTC (rev 59093) +++ firebird/trunk/src/common/config/config_file.cpp 2014-01-31 14:43:25 UTC (rev 59094) @@ -262,7 +262,7 @@ * Parse line, taking quotes into account */ -ConfigFile::LineType ConfigFile::parseLine(const char* fileName, const String& input, KeyType& key, String& value) +ConfigFile::LineType ConfigFile::parseLine(const char* fileName, const String& input, Parameter& par) { int inString = 0; String::size_type valStart = 0; @@ -276,7 +276,7 @@ switch (input[n]) { case '"': - if (key.isEmpty()) // quoted string to the left of = doesn't make sense + if (par.name.isEmpty()) // quoted string to the left of = doesn't make sense return LINE_BAD; if (inString >= 2) // one more quote after quoted string doesn't make sense return LINE_BAD; @@ -284,11 +284,11 @@ break; case '=': - if (key.isEmpty()) + if (par.name.isEmpty()) { - key = input.substr(0, n).ToNoCaseString(); - key.rtrim(" \t\r"); - if (key.isEmpty()) // not good - no key + par.name = input.substr(0, n).ToNoCaseString(); + par.name.rtrim(" \t\r"); + if (par.name.isEmpty()) // not good - no key return LINE_BAD; valStart = n + 1; } @@ -306,15 +306,15 @@ case ' ': case '\t': - if (n == incLen && key.isEmpty()) + if (n == incLen && par.name.isEmpty()) { KeyType inc = input.substr(0, n).ToNoCaseString(); if (inc == include) { - value = input.substr(n); - value.alltrim(" \t\r"); + par.value = input.substr(n); + par.value.alltrim(" \t\r"); - if (!macroParse(value, fileName)) + if (!macroParse(par.value, fileName)) { return LINE_BAD; } @@ -331,9 +331,16 @@ { if (inString != 1) { - if (input[n] == '}') // Subconf close mark not expected + if (input[n] == '}') { - return LINE_BAD; + String s = input.substr(n + 1); + s.ltrim(" \t\r"); + if (s.hasData() && s[0] != '#') + { + return LINE_BAD; + } + par.value = input.substr(0, n); + return LINE_END_SUB; } hasSub = true; @@ -354,21 +361,21 @@ if (inString == 1) // If we are still inside a string, it's error return LINE_BAD; - if (key.isEmpty()) + if (par.name.isEmpty()) { - key = input.substr(0, eol).ToNoCaseString(); - key.rtrim(" \t\r"); - value.erase(); + par.name = input.substr(0, eol).ToNoCaseString(); + par.name.rtrim(" \t\r"); + par.value.erase(); } else { - value = input.substr(valStart, eol - valStart); - value.alltrim(" \t\r"); - value.alltrim("\""); + par.value = input.substr(valStart, eol - valStart); + par.value.alltrim(" \t\r"); + par.value.alltrim("\""); } // Now expand macros in value - if (!macroParse(value, fileName)) + if (!macroParse(par.value, fileName)) { return LINE_BAD; } @@ -399,6 +406,9 @@ ++subTo; // Avoid double slashes in pathnames + PathUtils::setDirIterator(value.begin()); + PathUtils::setDirIterator(macro.begin()); + if (subFrom > 0 && value[subFrom - 1] == PathUtils::dir_sep && macro.length() > 0 && macro[0] == PathUtils::dir_sep) { @@ -585,7 +595,7 @@ Parameter current; current.line = line; - switch (parseLine(streamName, inputLine, current.name, current.value)) + switch (parseLine(streamName, inputLine, current)) { case LINE_BAD: badLine(streamName, inputLine); @@ -616,18 +626,23 @@ SubStream subStream(stream->getFileName()); while (stream->getLine(inputLine, line)) { - if (inputLine[0] == '}') + switch(parseLine(streamName, inputLine, current)) { - String s = inputLine.substr(1); - s.ltrim(" \t\r"); - if (s.hasData() && s[0] != '#') - { - badLine(streamName, s); - return; - } + case LINE_END_SUB: + if (current.value.hasData()) + subStream.putLine(current.value, line); break; + + //case LINE_START_SUB: will be ignored at next level. Ignore here? + case LINE_BAD: + badLine(streamName, inputLine); + return; + + default: + subStream.putLine(inputLine, line); + continue; } - subStream.putLine(inputLine, line); + break; } previous->sub = FB_NEW(getPool()) Modified: firebird/trunk/src/common/config/config_file.h =================================================================== --- firebird/trunk/src/common/config/config_file.h 2014-01-31 00:55:25 UTC (rev 59093) +++ firebird/trunk/src/common/config/config_file.h 2014-01-31 14:43:25 UTC (rev 59094) @@ -124,7 +124,7 @@ bool macroParse(String& value, const char* fileName) const; private: - enum LineType {LINE_BAD, LINE_REGULAR, LINE_START_SUB, LINE_INCLUDE}; + enum LineType {LINE_BAD, LINE_REGULAR, LINE_START_SUB, LINE_END_SUB, LINE_INCLUDE}; Parameters parameters; USHORT flags; @@ -134,7 +134,7 @@ // utilities void parse(Stream* stream); - LineType parseLine(const char* fileName, const String& input, KeyType& key, String& value); + LineType parseLine(const char* fileName, const String& input, Parameter& par); bool translate(const char* fileName, const String& from, String& to) const; void badLine(const char* fileName, const String& line); void include(const char* currentFileName, const Firebird::PathName& path); Modified: firebird/trunk/src/common/os/path_utils.h =================================================================== --- firebird/trunk/src/common/os/path_utils.h 2014-01-31 00:55:25 UTC (rev 59093) +++ firebird/trunk/src/common/os/path_utils.h 2014-01-31 14:43:25 UTC (rev 59094) @@ -162,6 +162,11 @@ dir_iterator being returned. **/ static dir_iterator* newDirItr(MemoryPool&, const Firebird::PathName&); + + /** setDirIterator converts all dir iterators to one required on current + platform. + **/ + static void setDirIterator(char* path); }; #endif // JRD_OS_PATH_UTILS_H Modified: firebird/trunk/src/common/os/posix/path_utils.cpp =================================================================== --- firebird/trunk/src/common/os/posix/path_utils.cpp 2014-01-31 00:55:25 UTC (rev 59093) +++ firebird/trunk/src/common/os/posix/path_utils.cpp 2014-01-31 14:43:25 UTC (rev 59094) @@ -192,3 +192,11 @@ return access(path.c_str(), mode) == 0; } +void PathUtils::setDirIterator(char* path) +{ + for (; *path; ++path) + { + if (*path == '\\') + *path = '/'; + } +} Modified: firebird/trunk/src/common/os/win32/path_utils.cpp =================================================================== --- firebird/trunk/src/common/os/win32/path_utils.cpp 2014-01-31 00:55:25 UTC (rev 59093) +++ firebird/trunk/src/common/os/win32/path_utils.cpp 2014-01-31 14:43:25 UTC (rev 59094) @@ -186,3 +186,12 @@ return _access(path.c_str(), mode) == 0; } +void PathUtils::setDirIterator(char* path) +{ + for (; *path; ++path) + { + if (*path == '/') + *path = '\\'; + } +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |