diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index f6b6c0680a3..a5981708ace 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -448,6 +448,9 @@ if ("${READLINE_FOUND}") set(HAVE_READLINE 1) endif() +if ("${PAM_FOUND}") + set(HAVE_PAM 1) +endif() set(have_tls "${HAVE_TLS}" ) @@ -654,6 +657,7 @@ MESSAGE(" TLS support: ${have_tls} ") MESSAGE(" Encryption support: ${have_crypto} ") MESSAGE(" OpenSSL support: ${OPENSSL_FOUND} ${OPENSSL_VERSION} ${OPENSSL_INCLUDE_DIR} ${OPENSSL_LIBRARIES} ") MESSAGE(" GNUTLS support: ${have_gnutls} ") +MESSAGE(" PAM support: ${PAM_FOUND} ${PAM_LIBRARIES} ${PAM_INCLUDE_DIRS} ") MESSAGE(" ZLIB support: ${ZLIB_FOUND} ${ZLIB_LIBRARIES} ${ZLIB_INCLUDE_DIRS} ") MESSAGE(" LZO2 support: ${LZO2_FOUND} ${LZO2_LIBRARIES} ${LZO2_INCLUDE_DIRS} ") MESSAGE(" FASTLZ support: ${FASTLZ_FOUND} ${FASTLZ_LIBRARIES} ${FASTLZ_INCLUDE_DIRS} ") diff --git a/core/src/console/CMakeLists.txt b/core/src/console/CMakeLists.txt index bd10ec4cca0..94f4d030b50 100644 --- a/core/src/console/CMakeLists.txt +++ b/core/src/console/CMakeLists.txt @@ -18,19 +18,24 @@ # 02110-1301, USA. -SET (BCONSSRCS auth_pam.cc console_conf.cc console_globals.cc console_output.cc) +SET (BCONSSRCS console_conf.cc console_globals.cc console_output.cc) IF(HAVE_WIN32) LIST(APPEND BCONSSRCS ../win32/console/consoleres.rc) ENDIF() +IF(HAVE_PAM) + include_directories(${PAM_INCLUDE_DIRS}) + LIST(APPEND BCONSSRCS auth_pam.cc) +ENDIF() + add_executable(bconsole console.cc) add_library(console_objects STATIC ${BCONSSRCS}) -set(CONSOLE_LINK_LIBRARIES console_objects bareos ${Readline_LIBRARY}) - -IF(HAVE_WIN32) - LIST(APPEND CONSOLE_LINK_LIBRARIES) +IF(HAVE_PAM) + set(CONSOLE_LINK_LIBRARIES console_objects bareos ${Readline_LIBRARY} ${PAM_LIBRARIES}) +ELSE() + set(CONSOLE_LINK_LIBRARIES console_objects bareos ${Readline_LIBRARY}) ENDIF() target_link_libraries(bconsole ${CONSOLE_LINK_LIBRARIES}) diff --git a/core/src/console/console.cc b/core/src/console/console.cc index ad6066f6d67..a9a7b7ef57c 100644 --- a/core/src/console/console.cc +++ b/core/src/console/console.cc @@ -31,7 +31,9 @@ #include "include/bareos.h" #include "console/console_conf.h" #include "console/console_globals.h" +#if defined(HAVE_PAM) #include "console/auth_pam.h" +#endif #include "console/console_output.h" #include "include/jcr.h" #include "lib/bnet.h" @@ -1083,14 +1085,16 @@ int main(int argc, char *argv[]) ConsoleOutput(errmsg); +#if defined(HAVE_PAM) if (console_resource) { /* not for root console */ - if (director_resource && director_resource->use_pam_authentication) { - if (!ConsolePamAuthenticate(stdin, UA_sock)) { - TerminateConsole(0); - return 1; - } + if (director_resource && director_resource->use_pam_authentication) { + if (!ConsolePamAuthenticate(stdin, UA_sock)) { + TerminateConsole(0); + return 1; + } } } +#endif /* HAVE_PAM */ Dmsg0(40, "Opened connection with Director daemon\n"); diff --git a/core/src/dird/CMakeLists.txt b/core/src/dird/CMakeLists.txt index 265f0efd7b2..fcfceb18d93 100644 --- a/core/src/dird/CMakeLists.txt +++ b/core/src/dird/CMakeLists.txt @@ -21,7 +21,7 @@ set(DIRDSRCS dird.cc) #DIRD_OBJECTS_SRCS also used in a separate library for unittests -set(DIRD_OBJECTS_SRCS admin.cc archive.cc authenticate.cc auth_pam.cc autoprune.cc backup.cc bsr.cc catreq.cc +set(DIRD_OBJECTS_SRCS admin.cc archive.cc authenticate.cc autoprune.cc backup.cc bsr.cc catreq.cc consolidate.cc dird_globals.cc dir_plugins.cc dird_conf.cc expand.cc fd_cmds.cc getmsg.cc inc_conf.cc job.cc jobq.cc migrate.cc mountreq.cc msgchan.cc ndmp_dma_storage.cc @@ -40,6 +40,11 @@ IF(HAVE_WIN32) LIST(APPEND DIRD_OBJECTS_SRCS ../win32/dird/dirdres.rc) ENDIF() +IF(HAVE_PAM) + include_directories(${PAM_INCLUDE_DIRS}) + LIST(APPEND DIRD_OBJECTS_SRCS auth_pam.cc) +ENDIF() + IF(HAVE_WIN32) include_directories(${CMAKE_SOURCE_DIR}/src/win32/generic ${CMAKE_SOURCE_DIR}/src/win32/dird) LIST(APPEND DIRDSRCS @@ -48,8 +53,6 @@ IF(HAVE_WIN32) ) ENDIF() -include_directories(${PAM_INCLUDE_DIRS}) - set(DBCHKSRCS dbcheck.cc dird_conf.cc dird_globals.cc ua_acl.cc ua_audit.cc run_conf.cc inc_conf.cc) IF(HAVE_WIN32) LIST(APPEND DBCHKSRCS ../win32/dird/dbcheckres.rc) @@ -75,37 +78,30 @@ set(BAREOS_DIR_LIBRARIES ) IF(HAVE_WIN32) - LIST(APPEND BAREOS_DIR_LIBRARIES - comctl32 - ) + LIST(APPEND BAREOS_DIR_LIBRARIES comctl32) ENDIF() -target_link_libraries(bareos-dir ${BAREOS_DIR_LIBRARIES} ${PAM_LIBRARIES}) - +IF(HAVE_PAM) + target_link_libraries(bareos-dir ${BAREOS_DIR_LIBRARIES} ${PAM_LIBRARIES}) +ELSE() + target_link_libraries(bareos-dir ${BAREOS_DIR_LIBRARIES}) +ENDIF() add_executable(bareos-dbcheck ${DBCHKSRCS}) SET(DBCHECK_LIBRARIES bareossql bareos bareosfind bareoscats) -IF(HAVE_WIN32) - LIST(APPEND DBCHECK_LIBRARIES) -ENDIF() - -target_link_libraries(bareos-dbcheck - ${DBCHECK_LIBRARIES} - ) - +target_link_libraries(bareos-dbcheck ${DBCHECK_LIBRARIES}) # is not built by default #add_executable(testfind ${TSTFNDSRCS}) -#target_link_libraries(testfind bareos bareosfind +#target_link_libraries(testfind bareos bareosfind # jansson ${OPENSSL_LIBS} acl cap lzo2 #) INSTALL(TARGETS bareos-dir bareos-dbcheck DESTINATION "${sbindir}") INSTALL(FILES query.sql DESTINATION "${scriptdir}") - install(CODE "set(PLUGINS \"${PLUGINS}\")") install(CODE "set(BACKENDS \"${BACKENDS}\")") install(CODE "set(configtemplatedir \"${configtemplatedir}\")") diff --git a/core/src/dird/ua_server.cc b/core/src/dird/ua_server.cc index 9629a40efd4..b3717eb73ef 100644 --- a/core/src/dird/ua_server.cc +++ b/core/src/dird/ua_server.cc @@ -32,7 +32,9 @@ #include "dird.h" #include "dird/dird_globals.h" #include "dird/authenticate.h" +#if defined(HAVE_PAM) #include "dird/auth_pam.h" +#endif #include "dird/job.h" #include "dird/ua_cmds.h" #include "dird/ua_db.h" @@ -87,6 +89,7 @@ void *HandleUserAgentClientRequest(BareosSocket *user_agent_socket) bool success = AuthenticateUserAgent(ua); +#if defined(HAVE_PAM) if (success) { std::string username; if (ua->cons) { @@ -94,6 +97,7 @@ void *HandleUserAgentClientRequest(BareosSocket *user_agent_socket) success = PamAuthenticateUseragent(ua->UA_sock, username); } } +#endif /* HAVE_PAM */ if (!success) { ua->quit = true; diff --git a/core/src/include/config.h.in b/core/src/include/config.h.in index 126c1d4a1e8..f5c46a3d9d6 100644 --- a/core/src/include/config.h.in +++ b/core/src/include/config.h.in @@ -43,6 +43,9 @@ /* Define to 1 if you want Normal acl support */ #cmakedefine HAVE_ACL @HAVE_ACL@ +/* Define to 1 if you want PAM support */ +#cmakedefine HAVE_PAM @HAVE_PAM@ + /* Defines if your system have the ACL_TYPE_DEFAULT_DIR acl type */ #cmakedefine HAVE_ACL_TYPE_DEFAULT_DIR @HAVE_ACL_TYPE_DEFAULT_DIR@ diff --git a/core/src/lib/unittests/CMakeLists.txt b/core/src/lib/unittests/CMakeLists.txt index 12b1cb4ac86..3aa53595b67 100644 --- a/core/src/lib/unittests/CMakeLists.txt +++ b/core/src/lib/unittests/CMakeLists.txt @@ -58,14 +58,13 @@ set_property(TEST test_lib add_dependencies(check test_lib) add_executable(test_bsock - bsock_test.cc - bsock_dir_sd_connection_test.cc - bsock_constructor_test.cc + bsock_test.cc + bsock_dir_sd_connection_test.cc + bsock_constructor_test.cc bsock_cert_verify_common_names_test.cc create_resource.cc ) - -target_link_libraries(test_bsock +set(LINK_LIBRARIES stored_objects dird_objects console_objects @@ -78,12 +77,15 @@ target_link_libraries(test_bsock ${NDMP_LIBS} ${JANSSON_LIBRARIES} ${GTEST_LIBRARIES} - ${GTEST_MAIN_LIBRARIES} - ${PAM_LIBRARIES}) + ${GTEST_MAIN_LIBRARIES}) -add_test(NAME test_bsock - COMMAND test_bsock - ) +IF(HAVE_PAM) + LIST(APPEND LINK_LIBRARIES ${PAM_LIBRARIES}) +ENDIF() + +target_link_libraries(test_bsock ${LINK_LIBRARIES}) + +add_test(NAME test_bsock COMMAND test_bsock) set_property(TEST test_bsock PROPERTY ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/src/lib:${CMAKE_BINARY_DIR}/src/stored:${CMAKE_BINARY_DIR}/src/cats:${CMAKE_BINARY_DIR}/src/findlib:${CMAKE_BINARY_DIR}/src/lmdb:${CMAKE_BINARY_DIR}/src/ndmp"