Merge pull request #699 from majestrate/disable-shell-hooks-compile

disable shell hooks by default
This commit is contained in:
Jeff 2019-07-12 09:50:49 -04:00 committed by GitHub
commit 96a4c027d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View File

@ -19,6 +19,7 @@ option(DEBIAN "build for debian" )
option(TESTNET "testnet build" )
option(WITH_SHARED "build shared library")
option(WITH_COVERAGE "generate coverage data")
option(WITH_SHELLHOOKS "enable shell hooks on compile time (dangerous)" OFF)
option(WARNINGS_AS_ERRORS "treat all warnings as errors. turn off for development, on for release" OFF)
include(cmake/target_link_libraries_system.cmake)
@ -94,6 +95,10 @@ if(NON_PC_TARGET)
set(WITH_STATIC ON)
endif(NON_PC_TARGET)
if(WITH_SHELLHOOKS)
add_definitions(-DENABLE_SHELLHOOKS)
endif(WITH_SHELLHOOKS)
add_compile_options(${OPTIMIZE_FLAGS} ${CRYPTO_FLAGS})
set(ABSEIL_DIR vendor/abseil-cpp)

View File

@ -61,6 +61,8 @@ NON_PC_TARGET ?= OFF
STATIC_LINK ?= OFF
# enable network namespace isolation
NETNS ?= OFF
# enable shell hooks callbacks
SHELL_HOOKS ?= OFF
# cross compile?
CROSS ?= OFF
# build liblokinet-shared.so
@ -86,13 +88,13 @@ SCAN_BUILD ?= scan-build
UNAME = $(shell which uname)
ifeq ($(shell $(UNAME)),SunOS)
CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_SHELLHOOKS=$(SHELL_HOOKS) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
ANALYZE_CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "$(SCAN_BUILD) cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
COVERAGE_CONFIG_CMD = $(shell gecho -n "cd '$(BUILD_ROOT)' && " ; gecho -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DWITH_COVERAGE=yes -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
else
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_SHELLHOOKS=$(SHELL_HOOKS) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")
ANALYZE_CONFIG_CMD = $(shell /bin/echo -n "cd '$(BUILD_ROOT)' && " ; /bin/echo -n "$(SCAN_BUILD) cmake -G'$(CMAKE_GEN)' -DCMAKE_CROSSCOMPILING=$(CROSS) -DSTATIC_LINK_RUNTIME=$(STATIC_LINK) -DUSE_NETNS=$(NETNS) -DUSE_AVX2=$(AVX2) -DNON_PC_TARGET=$(NON_PC_TARGET) -DWITH_SHARED=$(SHARED_LIB) -DCMAKE_EXPORT_COMPILE_COMMANDS=ON '$(REPO)'")

View File

@ -1,7 +1,6 @@
#include <hook/shell.hpp>
#if defined(_WIN32)
/** put win32 stuff here */
#else
#if defined(ENABLE_SHELLHOOKS)
#include <util/thread_pool.hpp>
#include <util/logger.hpp>
#include <sys/wait.h>
@ -10,21 +9,16 @@
// Not all systems declare this variable
extern char **environ;
#endif
#endif
#if defined(Darwin)
#include <crt_externs.h>
#endif
#endif
namespace llarp
{
namespace hooks
{
#if defined(_WIN32)
Backend_ptr ExecShellBackend(std::string)
{
return nullptr;
}
#else
#if defined(ENABLE_SHELLHOOKS)
struct ExecShellHookBackend
: public IBackend,
public std::enable_shared_from_this< ExecShellHookBackend >
@ -157,6 +151,11 @@ namespace llarp
return nullptr;
return ptr;
}
#else
Backend_ptr ExecShellBackend(std::string)
{
return nullptr;
}
#endif
} // namespace hooks
} // namespace llarp