diff --git a/.travis.yml b/.travis.yml index cb75952..fce4617 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,7 @@ addons: - python3-wheel - ninja-build - libconfig-dev + - libpam0g-dev - valgrind env: diff --git a/CMakeLists.txt b/CMakeLists.txt index 54e7b26..bfe643f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ project(webfused VERSION 0.1.0 DESCRIPTION "Webfuse daemon") option(WITHOUT_TESTS "disable unit tests" OFF) +set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") + set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) @@ -14,6 +16,7 @@ pkg_check_modules(UUID REQUIRED uuid) pkg_check_modules(LIBCONFIG REQUIRED libconfig) pkg_check_modules(OPENSSL REQUIRED openssl) pkg_check_modules(WEBFUSE REQUIRED libwebfuse-adapter) +find_package(Pam REQUIRED) add_definitions(-D_FILE_OFFSET_BITS=64) @@ -33,7 +36,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) set(C_WARNINGS -Wall -Wextra) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") include(coverage) add_library(userdb STATIC @@ -76,6 +78,7 @@ target_link_libraries(webfused PUBLIC ${OPENSSL_LIBRARIES} ${WEBFUSE_LIBRARIES} ${UUID_LIBRARIES} + ${PAM_LIBRARIES} ) target_compile_options(webfused PUBLIC ${OPENSSL_CFLAGS_OTHER}) @@ -130,6 +133,7 @@ add_executable(alltests test/test_stderr_logger.cc test/test_syslog_logger.cc test/test_daemon.cc + test/test_pam.cc ) target_include_directories(alltests PRIVATE @@ -165,6 +169,7 @@ target_link_libraries(alltests PRIVATE ${LIBCONFIG_LIBRARIES} ${WEBFUSE_LIBRARIES} ${UUID_LIBRARIES} + ${PAM_LIBRARIES} ${OPENSSL_LIBRARIES} ${GMOCK_LIBRARIES} ${GTEST_LIBRARIES} diff --git a/README.md b/README.md index 92b59de..de31921 100644 --- a/README.md +++ b/README.md @@ -180,6 +180,7 @@ switch to *user* and *group* provided in config file. - [jansson](https://github.com/akheron/jansson) - [openssl](https://www.openssl.org/) - [libconfig](https://hyperrealm.github.io/libconfig/) +- [linux-pam](http://www.linux-pam.org/) - [Google Test](https://github.com/google/googletest) *(Test only)* ### Installing dependencies @@ -240,6 +241,11 @@ To install libfuse, meson is needed. Please refer to [meson quick guide](https:/ sudo apt update sudo apt install libconfig-dev +#### linux-pam + + sudo apt update + sudo apt install libpam0g-dev + #### GoogleTest Installation of GoogleTest is optional webfuse library, but required to compile tests. diff --git a/cmake/FindPam.cmake b/cmake/FindPam.cmake new file mode 100644 index 0000000..181be36 --- /dev/null +++ b/cmake/FindPam.cmake @@ -0,0 +1,22 @@ +find_package(PkgConfig) +pkg_check_modules(PC_PAM QUIET pam) +set(PAM_DEFINITIONS ${PC_PAM_CFLAGS_OTHER}) + +find_path(PAM_INCLUDE_DIR security/pam_appl.h + HINTS ${PC_PAM_INCLUDEDIR} ${PC_PAM_INCLUDE_DIRS} +) + +find_library(PAM_LIBRARY NAMES pam + HINTS ${PC_PAM_LIBDIR} ${PC_PAM_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args(Pam DEFAULT_MSG + PAM_LIBRARY PAM_INCLUDE_DIR +) + +mark_as_advanced(PAM_INCLUDE_DIR PAM_LIBRARY) + +set(PAM_LIBRARIES ${PAM_LIBRARY}) +set(PAM_INCLUDE_DIRS ${PAM_INCLUDE_DIR}) diff --git a/test/test_pam.cc b/test/test_pam.cc new file mode 100644 index 0000000..0f16bac --- /dev/null +++ b/test/test_pam.cc @@ -0,0 +1,13 @@ +#include +#include + +TEST(pam, start) +{ + pam_handle_t * handle = nullptr; + struct pam_conv conv = { nullptr, nullptr }; + int rc = pam_start("test", nullptr, &conv, &handle); + if (PAM_SUCCESS == rc) + { + pam_end(handle, 0); + } +} \ No newline at end of file