From 21b0d29e381518f3611ffc39c0a0b3dd30b2309e Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 15 Apr 2014 21:13:42 +0200 Subject: [PATCH] cmake: Configure nss_wrapper and uid_wrapper Signed-off-by: Andreas Schneider --- tests/CMakeLists.txt | 20 ++++++++++++++++++++ tests/etc/group.in | 5 +++++ tests/etc/hosts.in | 2 ++ tests/etc/passwd.in | 5 +++++ tests/etc/shadow.in | 2 ++ 5 files changed, 34 insertions(+) create mode 100644 tests/etc/group.in create mode 100644 tests/etc/hosts.in create mode 100644 tests/etc/passwd.in create mode 100644 tests/etc/shadow.in diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 94939560..04838f03 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -46,6 +46,8 @@ add_subdirectory(unittests) if (WITH_CLIENT_TESTING) find_package(socket_wrapper 1.1.5 REQUIRED) find_package(nss_wrapper 1.1.2 REQUIRED) + find_package(uid_wrapper 1.2.0 REQUIRED) + find_program(SSHD_EXECUTABLE NAME sshd @@ -56,6 +58,24 @@ if (WITH_CLIENT_TESTING) if (NOT SSHD_EXECUTABLE) message(SEND_ERROR "Could not find sshd which is required for client testing") endif() + + # homedir will be used in passwd + set(HOMEDIR ${CMAKE_CURRENT_BINARY_DIR}/home) + + ### Setup nss_wrapper + configure_file(etc/passwd.in ${CMAKE_CURRENT_BINARY_DIR}/etc/passwd @ONLY) + configure_file(etc/shadow.in ${CMAKE_CURRENT_BINARY_DIR}/etc/shadow @ONLY) + configure_file(etc/group.in ${CMAKE_CURRENT_BINARY_DIR}/etc/group @ONLY) + configure_file(etc/hosts.in ${CMAKE_CURRENT_BINARY_DIR}/etc/hosts @ONLY) + + set(TORTURE_ENVIRONMENT "LD_PRELOAD=${SOCKET_WRAPPER_LIBRARY}:${NSS_WRAPPER_LIBRARY}:${UID_WRAPPER_LIBRARY}") + list(APPEND TORTURE_ENVIRONMENT UID_WRAPPER=1) + list(APPEND TORTURE_ENVIRONMENT NSS_WRAPPER_PASSWD=${CMAKE_CURRENT_BINARY_DIR}/etc/passwd) + list(APPEND TORTURE_ENVIRONMENT NSS_WRAPPER_SHADOW=${CMAKE_CURRENT_BINARY_DIR}/etc/shadow) + list(APPEND TORTURE_ENVIRONMENT NSS_WRAPPER_GROUP=${CMAKE_CURRENT_BINARY_DIR}/etc/group) + + message(STATUS "TORTURE_ENVIRONMENT=${TORTURE_ENVIRONMENT}") + add_subdirectory(client) endif (WITH_CLIENT_TESTING) diff --git a/tests/etc/group.in b/tests/etc/group.in new file mode 100644 index 00000000..b6e85eff --- /dev/null +++ b/tests/etc/group.in @@ -0,0 +1,5 @@ +users:x:1000: +sshd:x:65531: +nobody:x:65533: +nogroup:x:65534:nobody +root:x:65532: diff --git a/tests/etc/hosts.in b/tests/etc/hosts.in new file mode 100644 index 00000000..2ab69799 --- /dev/null +++ b/tests/etc/hosts.in @@ -0,0 +1,2 @@ +127.0.0.10 server.libssh.site +127.0.0.21 client.libssh.site diff --git a/tests/etc/passwd.in b/tests/etc/passwd.in new file mode 100644 index 00000000..5844c1d1 --- /dev/null +++ b/tests/etc/passwd.in @@ -0,0 +1,5 @@ +bob:x:1000:1000:bob gecos:@HOMEDIR@/bob:/bin/false +alice:x:1001:1000:alice gecos:@HOMEDIR@/alice:/bin/bash +sshd:x:65530:65531:sshd:@HOMEDIR@:/sbin/nologin +nobody:x:65533:65534:nobody gecos:@HOMEDIR@:/bin/false +root:x:65534:65532:root gecos:@HOMEDIR@:/bin/false diff --git a/tests/etc/shadow.in b/tests/etc/shadow.in new file mode 100644 index 00000000..5c0e3d86 --- /dev/null +++ b/tests/etc/shadow.in @@ -0,0 +1,2 @@ +alice:$6$0jWkA8VP$MvBUvtGy38jWCZ5KtqnZEKQWXvvImDkDhDQII1kTqtAp3/xH31b71c.AjGkBFle.2QwCJQH7OzB/NXiMprusr/::0::::: +bob:$6$0jWkA8VP$MvBUvtGy38jWCZ5KtqnZEKQWXvvImDkDhDQII1kTqtAp3/xH31b71c.AjGkBFle.2QwCJQH7OzB/NXiMprusr/::0:::::