2020-02-09 14:04:58 +00:00
|
|
|
cmake_minimum_required (VERSION 3.10)
|
2020-03-20 15:59:07 +00:00
|
|
|
project(webfused VERSION 0.3.0 DESCRIPTION "Webfuse daemon")
|
2020-02-09 14:04:58 +00:00
|
|
|
|
2020-03-02 21:18:25 +00:00
|
|
|
option(WITHOUT_TESTS "disable unit tests" OFF)
|
|
|
|
|
2020-03-19 17:33:16 +00:00
|
|
|
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
|
|
|
|
2020-02-09 14:04:58 +00:00
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
|
|
find_package(PkgConfig REQUIRED)
|
|
|
|
pkg_check_modules(FUSE3 REQUIRED fuse3)
|
|
|
|
pkg_check_modules(LWS REQUIRED libwebsockets)
|
|
|
|
pkg_check_modules(JANSSON REQUIRED jansson)
|
|
|
|
pkg_check_modules(UUID REQUIRED uuid)
|
2020-03-02 20:55:39 +00:00
|
|
|
pkg_check_modules(LIBCONFIG REQUIRED libconfig)
|
2020-02-09 14:04:58 +00:00
|
|
|
pkg_check_modules(OPENSSL REQUIRED openssl)
|
|
|
|
pkg_check_modules(WEBFUSE REQUIRED libwebfuse-adapter)
|
2020-03-19 17:33:16 +00:00
|
|
|
find_package(Pam REQUIRED)
|
2020-02-09 14:04:58 +00:00
|
|
|
|
|
|
|
add_definitions(-D_FILE_OFFSET_BITS=64)
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
"src"
|
|
|
|
${WEBFUSE_INCLUDE_DIRS}
|
|
|
|
)
|
|
|
|
|
|
|
|
link_directories(
|
|
|
|
${WEBFUSE_LIBRARY_DIRS}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
set(C_WARNINGS -Wall -Wextra)
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
2020-03-02 21:31:11 +00:00
|
|
|
include(coverage)
|
|
|
|
|
2020-02-09 14:04:58 +00:00
|
|
|
add_library(userdb STATIC
|
|
|
|
src/userdb/userdb.c
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(userdb PUBLIC
|
2020-03-02 20:55:39 +00:00
|
|
|
${LIBCONFIG_INCLUDE_DIRS}
|
2020-02-09 14:04:58 +00:00
|
|
|
${OPENSSL_INCLUDE_DIRS}
|
|
|
|
${JANSSON_INCLUDE_DIRS}
|
|
|
|
)
|
|
|
|
|
|
|
|
target_compile_options(userdb PUBLIC ${OPENSSL_CFLAGS_OTHER})
|
|
|
|
|
2020-03-08 10:44:17 +00:00
|
|
|
add_library(webfused-static STATIC
|
2020-03-08 15:14:55 +00:00
|
|
|
src/webfused/daemon.c
|
2020-03-17 20:51:04 +00:00
|
|
|
src/webfused/mountpoint_factory.c
|
2020-03-19 11:42:47 +00:00
|
|
|
src/webfused/change_user.c
|
2020-03-08 15:14:55 +00:00
|
|
|
src/webfused/config/config.c
|
|
|
|
src/webfused/config/factory.c
|
2020-03-18 09:17:17 +00:00
|
|
|
src/webfused/config/settings.c
|
2020-03-16 20:50:31 +00:00
|
|
|
src/webfused/auth/authenticator.c
|
|
|
|
src/webfused/auth/factory.c
|
|
|
|
src/webfused/auth/file_authenticator.c
|
2020-03-19 20:53:49 +00:00
|
|
|
src/webfused/auth/pam_authenticator.c
|
2020-03-18 16:33:31 +00:00
|
|
|
src/webfused/log/log.c
|
2020-03-08 18:45:49 +00:00
|
|
|
src/webfused/log/logger.c
|
2020-03-18 16:33:31 +00:00
|
|
|
src/webfused/log/manager.c
|
2020-03-17 21:53:38 +00:00
|
|
|
src/webfused/log/stderr_logger.c
|
2020-03-18 08:38:25 +00:00
|
|
|
src/webfused/log/syslog_logger.c
|
2020-03-08 15:14:55 +00:00
|
|
|
)
|
2020-02-09 14:04:58 +00:00
|
|
|
|
|
|
|
add_executable(webfused
|
2020-03-08 10:44:17 +00:00
|
|
|
src/webfused/main.c
|
2020-02-09 14:04:58 +00:00
|
|
|
)
|
|
|
|
|
2020-03-08 10:44:17 +00:00
|
|
|
target_link_libraries(webfused PUBLIC
|
|
|
|
webfused-static
|
2020-02-09 14:04:58 +00:00
|
|
|
userdb
|
2020-03-02 20:55:39 +00:00
|
|
|
${LIBCONFIG_LIBRARIES}
|
2020-02-09 14:04:58 +00:00
|
|
|
${OPENSSL_LIBRARIES}
|
|
|
|
${WEBFUSE_LIBRARIES}
|
|
|
|
${UUID_LIBRARIES}
|
2020-03-19 17:33:16 +00:00
|
|
|
${PAM_LIBRARIES}
|
2020-02-09 14:04:58 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
target_compile_options(webfused PUBLIC ${OPENSSL_CFLAGS_OTHER})
|
2020-02-09 19:04:54 +00:00
|
|
|
install(TARGETS webfused DESTINATION bin)
|
2020-02-09 14:04:58 +00:00
|
|
|
|
|
|
|
add_executable(webfuse-passwd
|
|
|
|
src/passwd/main.c
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(webfuse-passwd PUBLIC
|
|
|
|
userdb
|
|
|
|
${OPENSSL_LIBRARIES}
|
|
|
|
${JANSSON_LIBRARIES}
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(webfuse-passwd PUBLIC
|
|
|
|
example/passwd
|
|
|
|
example/lib/userdb/include
|
|
|
|
${OPENSSL_INCLUDE_DIRS}
|
|
|
|
${JANSSON_INCLUDE_DIRS}
|
|
|
|
)
|
|
|
|
|
|
|
|
target_compile_options(webfuse-passwd PUBLIC ${OPENSSL_CFLAGS_OTHER})
|
2020-02-09 19:04:54 +00:00
|
|
|
install(TARGETS webfuse-passwd DESTINATION bin)
|
2020-03-02 21:18:25 +00:00
|
|
|
|
|
|
|
if(NOT WITHOUT_TESTS)
|
|
|
|
|
|
|
|
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
|
|
|
|
|
|
include (CTest)
|
|
|
|
|
|
|
|
pkg_check_modules(GTEST gtest_main)
|
|
|
|
include(GoogleTest)
|
|
|
|
pkg_check_modules(GMOCK gmock)
|
|
|
|
|
|
|
|
add_executable(alltests
|
2020-03-20 12:48:58 +00:00
|
|
|
test/mock/config_builder.cc
|
|
|
|
test/mock/logger.cc
|
|
|
|
test/mock/credentials.cc
|
|
|
|
test/mock/settings.cc
|
|
|
|
test/mock/pam.cc
|
|
|
|
test/mock/libconfig.cc
|
|
|
|
test/mock/linux.cc
|
|
|
|
test/mock/server.cc
|
2020-03-20 14:10:58 +00:00
|
|
|
test/config/configfile.cc
|
|
|
|
test/config/configfile_version.cc
|
|
|
|
test/config/configfile_server.cc
|
|
|
|
test/config/configfile_auth.cc
|
|
|
|
test/config/configfile_filesystem.cc
|
|
|
|
test/config/configfile_log.cc
|
|
|
|
test/config/configfile_user.cc
|
2020-03-20 12:48:58 +00:00
|
|
|
test/config/config.cc
|
|
|
|
test/config/settings.cc
|
|
|
|
test/auth/factory.cc
|
|
|
|
test/auth/file_authenticator.cc
|
|
|
|
test/auth/pam_authenticator.cc
|
|
|
|
test/log/log.cc
|
|
|
|
test/log/log_manager.cc
|
|
|
|
test/log/stderr_logger.cc
|
|
|
|
test/log/syslog_logger.cc
|
|
|
|
test/daemon.cc
|
|
|
|
test/change_user.cc
|
|
|
|
test/mountpoint_factory.cc
|
|
|
|
test/userdb.cc
|
2020-03-02 21:18:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories(alltests PRIVATE
|
|
|
|
src
|
2020-03-20 12:48:58 +00:00
|
|
|
test
|
2020-03-02 21:18:25 +00:00
|
|
|
${GMOCK_INCLUDE_DIRS}
|
|
|
|
${GTEST_INCLUDE_DIRS}
|
|
|
|
)
|
|
|
|
|
|
|
|
target_compile_options(alltests PRIVATE ${GMOCK_CFLAGS} ${GTEST_CFLAGS} "-pthread")
|
|
|
|
|
|
|
|
target_link_libraries(alltests PRIVATE
|
2020-03-17 12:17:33 +00:00
|
|
|
-Wl,--wrap=wf_credentials_type
|
|
|
|
-Wl,--wrap=wf_credentials_get
|
2020-03-19 16:25:26 +00:00
|
|
|
|
2020-03-20 10:32:45 +00:00
|
|
|
-Wl,--wrap=wf_server_create
|
|
|
|
|
2020-03-18 16:33:31 +00:00
|
|
|
-Wl,--wrap=wfd_settings_get_string
|
|
|
|
-Wl,--wrap=wfd_settings_get_string_or_default
|
|
|
|
-Wl,--wrap=wfd_settings_get_bool
|
2020-03-19 16:25:26 +00:00
|
|
|
|
|
|
|
-Wl,--wrap=wfd_config_create
|
|
|
|
-Wl,--wrap=wfd_config_dispose
|
|
|
|
-Wl,--wrap=wfd_config_set_server_vhostname
|
|
|
|
-Wl,--wrap=wfd_config_set_server_port
|
|
|
|
-Wl,--wrap=wfd_config_set_server_key
|
|
|
|
-Wl,--wrap=wfd_config_set_server_cert
|
|
|
|
-Wl,--wrap=wfd_config_set_server_document_root
|
|
|
|
-Wl,--wrap=wfd_config_add_auth_provider
|
|
|
|
-Wl,--wrap=wfd_config_add_filesystem
|
|
|
|
-Wl,--wrap=wfd_config_set_logger
|
|
|
|
-Wl,--wrap=wfd_config_set_user
|
|
|
|
|
2020-03-19 20:53:49 +00:00
|
|
|
-Wl,--wrap=pam_start
|
|
|
|
-Wl,--wrap=pam_end
|
|
|
|
-Wl,--wrap=pam_strerror
|
|
|
|
-Wl,--wrap=pam_authenticate
|
|
|
|
-Wl,--wrap=pam_acct_mgmt
|
|
|
|
|
2020-03-20 09:26:41 +00:00
|
|
|
-Wl,--wrap=config_setting_get_elem
|
|
|
|
|
|
|
|
-Wl,--wrap=getuid
|
|
|
|
-Wl,--wrap=getgrnam
|
|
|
|
-Wl,--wrap=setgid
|
|
|
|
-Wl,--wrap=setgroups
|
|
|
|
-Wl,--wrap=getpwnam
|
|
|
|
-Wl,--wrap=setuid
|
|
|
|
|
2020-03-08 15:14:55 +00:00
|
|
|
webfused-static
|
2020-03-17 12:17:33 +00:00
|
|
|
userdb
|
2020-03-02 21:18:25 +00:00
|
|
|
${LIBCONFIG_LIBRARIES}
|
2020-03-15 21:35:57 +00:00
|
|
|
${WEBFUSE_LIBRARIES}
|
|
|
|
${UUID_LIBRARIES}
|
2020-03-19 17:33:16 +00:00
|
|
|
${PAM_LIBRARIES}
|
2020-03-17 12:17:33 +00:00
|
|
|
${OPENSSL_LIBRARIES}
|
2020-03-02 21:18:25 +00:00
|
|
|
${GMOCK_LIBRARIES}
|
|
|
|
${GTEST_LIBRARIES}
|
|
|
|
${CMAKE_THREAD_LIBS_INIT}
|
|
|
|
)
|
|
|
|
|
|
|
|
# copy test data
|
|
|
|
configure_file(etc/webfused.conf webfused.conf COPYONLY)
|
2020-03-16 20:50:31 +00:00
|
|
|
configure_file(test/invalid.conf invalid.conf COPYONLY)
|
2020-03-17 12:17:33 +00:00
|
|
|
configure_file(test/test_passwd.json test_passwd.json COPYONLY)
|
2020-03-02 21:18:25 +00:00
|
|
|
|
|
|
|
enable_testing()
|
|
|
|
gtest_discover_tests(alltests TEST_PREFIX alltests:)
|
|
|
|
|
2020-03-02 21:31:11 +00:00
|
|
|
add_custom_target(check
|
|
|
|
./alltests)
|
|
|
|
add_dependencies(check alltests)
|
|
|
|
|
|
|
|
add_custom_target(memcheck
|
2020-03-20 08:48:59 +00:00
|
|
|
valgrind --leak-check=full --error-exitcode=1 ./alltests)
|
2020-03-02 21:31:11 +00:00
|
|
|
add_dependencies(memcheck alltests)
|
|
|
|
|
|
|
|
add_custom_target(coverage
|
|
|
|
mkdir -p coverage
|
2020-03-17 12:08:42 +00:00
|
|
|
COMMAND lcov --initial --capture --directory . --output-file coverage/lcov_base.info --rc lcov_branch_coverage=1
|
2020-03-02 21:31:11 +00:00
|
|
|
COMMAND ./alltests
|
2020-03-17 12:08:42 +00:00
|
|
|
COMMAND lcov --capture --directory . --output-file coverage/lcov.info --rc lcov_branch_coverage=1
|
|
|
|
COMMAND lcov -a coverage/lcov_base.info -a coverage/lcov.info --output-file coverage/lcov.info --rc lcov_branch_coverage=1
|
|
|
|
COMMAND lcov --remove coverage/lcov.info '/usr/*' --output-file coverage/lcov.info --rc lcov_branch_coverage=1
|
|
|
|
COMMAND lcov --remove coverage/lcov.info '*/test/*' --output-file coverage/lcov.info --rc lcov_branch_coverage=1
|
2020-03-18 17:00:53 +00:00
|
|
|
COMMAND lcov --remove coverage/lcov.info '*/main.c' --output-file coverage/lcov.info --rc lcov_branch_coverage=1
|
2020-03-02 21:31:11 +00:00
|
|
|
)
|
|
|
|
add_dependencies(coverage alltests)
|
|
|
|
|
|
|
|
add_custom_target(coverage-report
|
2020-03-17 12:08:42 +00:00
|
|
|
COMMAND genhtml --branch-coverage --highlight --legend coverage/lcov.info --output-directory coverage/report
|
2020-03-02 21:31:11 +00:00
|
|
|
)
|
|
|
|
add_dependencies(coverage-report coverage)
|
|
|
|
|
|
|
|
|
2020-03-02 21:18:25 +00:00
|
|
|
endif(NOT WITHOUT_TESTS)
|