From 11a85ed29fe2714697937852e2a379653a6bd6ba Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sat, 24 Sep 2016 13:16:26 +0200 Subject: [PATCH] Allow building with -DCRYFS_UPDATE_CHECKS=off, which will create an executable with disabled update checks (the alternative to disable them in the environment also still works). --- CMakeLists.txt | 7 ++++++- ChangeLog.txt | 3 +++ README.md | 1 + src/cryfs-cli/CMakeLists.txt | 4 ++++ src/cryfs-cli/Cli.cpp | 4 ++++ test/cryfs-cli/CMakeLists.txt | 1 + 6 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 006754c9..dcecefa6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ require_clang_version(3.7) # Default value is not to build test cases if(NOT BUILD_TESTING) - set(BUILD_TESTING OFF CACHE INTERNAL "BUILD_TESTING") + set(BUILD_TESTING OFF CACHE BOOL "BUILD_TESTING") endif(NOT BUILD_TESTING) # Default vaule is to build in release mode @@ -17,6 +17,11 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release CACHE INTERNAL "CMAKE_BUILD_TYPE") endif(NOT CMAKE_BUILD_TYPE) +# Default value is to do update checks +if(NOT CRYFS_UPDATE_CHECKS) + set(CRYFS_UPDATE_CHECKS ON CACHE BOOL "CRYFS_UPDATE_CHECKS") +endif(NOT CRYFS_UPDATE_CHECKS) + add_subdirectory(vendor) add_subdirectory(src) add_subdirectory(test) diff --git a/ChangeLog.txt b/ChangeLog.txt index 736ec295..fabafde5 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -3,6 +3,9 @@ Version 0.9.6 (unreleased) Fixed bugs: * Fix potential (although very improbable) deadlock +Improvements: +* Allow building with -DCRYFS_UPDATE_CHECKS=off, which will create an executable with disabled update checks (the alternative to disable them in the environment also still works). + Compatibility: * Compatible with libcurl version >= 7.50.0, and <= 7.21.6 (tested down to 7.19.0) * Compatible with Crypto++ 5.6.4 diff --git a/README.md b/README.md index 103b0daf..2fcf5f1b 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ Build & Install You can pass the following variables to the *cmake* command (using *-Dvariablename=value*): - -D**CMAKE_BUILD_TYPE**=[Release|Debug]: Whether to run code optimization or add debug symbols. Default: Release - -D**BUILD_TESTING**=[on|off]: Whether to build the test cases (can take a long time). Default: off + - -D**CRYFS_UPDATE_CHECKS**=off: Build a CryFS that doesn't check online for updates and security vulnerabilities. Troubleshooting --------------- diff --git a/src/cryfs-cli/CMakeLists.txt b/src/cryfs-cli/CMakeLists.txt index 87e891c0..69a6b540 100644 --- a/src/cryfs-cli/CMakeLists.txt +++ b/src/cryfs-cli/CMakeLists.txt @@ -15,6 +15,10 @@ target_link_libraries(${PROJECT_NAME} PUBLIC cryfs cpp-utils gitversion) target_enable_style_warnings(${PROJECT_NAME}) target_activate_cpp14(${PROJECT_NAME}) +if(NOT CRYFS_UPDATE_CHECKS) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DCRYFS_NO_UPDATE_CHECKS) +endif(NOT CRYFS_UPDATE_CHECKS) + add_executable(${PROJECT_NAME}_bin main.cpp) set_target_properties(${PROJECT_NAME}_bin PROPERTIES OUTPUT_NAME cryfs) target_link_libraries(${PROJECT_NAME}_bin PUBLIC ${PROJECT_NAME}) diff --git a/src/cryfs-cli/Cli.cpp b/src/cryfs-cli/Cli.cpp index 74714840..32fb89b7 100644 --- a/src/cryfs-cli/Cli.cpp +++ b/src/cryfs-cli/Cli.cpp @@ -90,11 +90,15 @@ namespace cryfs { #ifndef NDEBUG cout << "WARNING! This is a debug build. Performance might be slow." << endl; #endif +#ifndef CRYFS_NO_UPDATE_CHECKS if (!Environment::noUpdateCheck()) { _checkForUpdates(); } else { cout << "Automatic checking for security vulnerabilities and updates is disabled." << endl; } +#else +# warning Update checks are disabled. The resulting executable will not go online to check for newer versions or known security vulnerabilities. +#endif cout << endl; } diff --git a/test/cryfs-cli/CMakeLists.txt b/test/cryfs-cli/CMakeLists.txt index cea04dcd..e9e62ee6 100644 --- a/test/cryfs-cli/CMakeLists.txt +++ b/test/cryfs-cli/CMakeLists.txt @@ -19,3 +19,4 @@ add_test(${PROJECT_NAME} ${PROJECT_NAME}) target_enable_style_warnings(${PROJECT_NAME}) target_activate_cpp14(${PROJECT_NAME}) +