Skip to content

Commit

Permalink
pam: removed pam from win32 build
Browse files Browse the repository at this point in the history
  • Loading branch information
franku committed Sep 21, 2018
1 parent 3ad1933 commit 4f9b3e3
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 38 deletions.
15 changes: 10 additions & 5 deletions core/src/console/CMakeLists.txt
Expand Up @@ -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})
Expand Down
14 changes: 9 additions & 5 deletions core/src/console/console.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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");

Expand Down
32 changes: 14 additions & 18 deletions core/src/dird/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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}\")")
Expand Down
4 changes: 4 additions & 0 deletions core/src/dird/ua_server.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -87,13 +89,15 @@ void *HandleUserAgentClientRequest(BareosSocket *user_agent_socket)

bool success = AuthenticateUserAgent(ua);

#if defined(HAVE_PAM)
if (success) {
std::string username;
if (ua->cons) {
username = ua->cons->name();
success = PamAuthenticateUseragent(ua->UA_sock, username);
}
}
#endif /* HAVE_PAM */

if (!success) {
ua->quit = true;
Expand Down
22 changes: 12 additions & 10 deletions core/src/lib/unittests/CMakeLists.txt
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 4f9b3e3

Please sign in to comment.