# HG changeset patch # User Sebastien Jodogne # Date 1562657513 -7200 # Node ID cbbe0bb80bd46e8cbf47f8474efe4b2c07387824 # Parent 4e34fd3e226a63161b25feade8db444c716603ce explicit error message if missing /etc/localtime diff -r 4e34fd3e226a -r cbbe0bb80bd4 Core/Toolbox.cpp --- 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 "" diff -r 4e34fd3e226a -r cbbe0bb80bd4 Resources/CMake/Compiler.cmake --- 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)