Mercurial > hg > orthanc
changeset 3459:cbbe0bb80bd4
explicit error message if missing /etc/localtime
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 09 Jul 2019 09:31:53 +0200 |
parents | 4e34fd3e226a |
children | 7fc9dd4882ec |
files | Core/Toolbox.cpp Resources/CMake/Compiler.cmake |
diffstat | 2 files changed, 27 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/Core/Toolbox.cpp Mon Jul 08 08:47:48 2019 +0200 +++ b/Core/Toolbox.cpp Tue Jul 09 09:31:53 2019 +0200 @@ -144,6 +144,10 @@ +#if defined(__unix__) && ORTHANC_SANDBOXED != 1 +# include "SystemToolbox.h" // Check out "InitializeGlobalLocale()" +#endif + namespace Orthanc @@ -1416,8 +1420,6 @@ static bool SetGlobalLocale(const char* locale) { - globalLocale_.reset(NULL); - try { if (locale == NULL) @@ -1431,8 +1433,12 @@ globalLocale_.reset(new std::locale(locale)); } } - catch (std::runtime_error&) + catch (std::runtime_error& e) { + LOG(ERROR) << "Cannot set globale locale to " + << (locale ? std::string(locale) : "(null)") + << ": " << e.what(); + globalLocale_.reset(NULL); } return (globalLocale_.get() != NULL); @@ -1538,6 +1544,23 @@ { InitializeIcu(); +#if defined(__unix__) && ORTHANC_SANDBOXED != 1 + static const char* LOCALTIME = "/etc/localtime"; + + if (!SystemToolbox::IsExistingFile(LOCALTIME)) + { + // Check out file + // "boost_1_69_0/libs/locale/src/icu/time_zone.cpp": Direct + // access is made to this file if ICU is not used. Crash arises + // in Boost if the file is a symbolic link to a non-existing + // file (such as in Ubuntu 16.04 base Docker image). + throw OrthancException( + ErrorCode_InternalError, + "On UNIX-like systems, the file " + std::string(LOCALTIME) + + " must be present on the filesystem (install \"tzdata\" package on Debian)"); + } +#endif + // Make Orthanc use English, United States locale // Linux: use "en_US.UTF-8" // Windows: use ""
--- a/Resources/CMake/Compiler.cmake Mon Jul 08 08:47:48 2019 +0200 +++ b/Resources/CMake/Compiler.cmake Tue Jul 09 09:31:53 2019 +0200 @@ -164,7 +164,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MINGW_NO_WARNINGS}") # This is a patch for MinGW64 - SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++") + SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++") SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++") CHECK_LIBRARY_EXISTS(winpthread pthread_create "" HAVE_WIN_PTHREAD)