Group: Security/Development
BuildRequires: pkgconfig(gtest)
BuildRequires: pkgconfig(cynara-admin)
+%if "%{?dev_wos}" != "1"
BuildRequires: pkgconfig(libsmack)
+%endif
Requires: %{name} = %{version}-%{release}
%description unittests
%endif
%if 0%{?no_feature_check:1} || "%_repository" == "emulator"
-DNO_FEATURE_CHECK= \
+%endif
+%if "%{?dev_wos}" != "1"
+ -DSMACK_ENABLED=ON \
%endif
-DHYBRID_PLUGIN_SO_PATH=%{hybrid_plugin_so_path} \
#include <utils.h>
#include <array>
+#include "cynara.h"
#include "request-mc.h"
#include "request-ga.h"
-#define SMACK_LABEL_LEN 255
namespace WA {
LogError("Error on get credentials");
return -1;
}
- if (m_credentials.smack == nowCreds.smack && m_credentials.cred.pid == nowCreds.cred.pid)
+ if (m_credentials.cynaraClient == nowCreds.cynaraClient &&
+ m_credentials.cred.pid == nowCreds.cred.pid)
{
return 1;
}
}
LogDebug("Client PID: " << creds->cred.pid);
- std::vector<char> result(SMACK_LABEL_LEN + 1);
- length = SMACK_LABEL_LEN;
- if (0 != (ret = getsockopt(connectionID.sock, SOL_SOCKET, SO_PEERSEC, result.data(), &length)))
- {
- LogError("getsockopt for get smack label failed" << get_error_message(ret));
+ if (!Cynara::GetClientFromSocket(connectionID.sock, creds->cynaraClient))
return -1;
- }
- creds->smack.assign(result.data(), length);
- LogDebug("Client Smack: " << creds->smack);
+
+ LogDebug("Cynara client: " << creds->cynaraClient);
return 0;
}
MessageBuffer buffer;
};
struct Cred {
- std::string smack;
+ std::string cynaraClient;
ucred cred;
};
int SetCredentials(SocketManager::ConnectionID connectionID);
/**
- * Get credentials for the connection. The smack label and process ID used to the credentials.
+ * Get credentials for the connection. The cynara client and process ID used to the credentials.
* @param[in] connectionID Socket information for the connection
* @param[out] creds Credentials for the connection
* @return @c 0 on success,
SocketManager::ServiceDescription GetServiceDescription() override {
return SocketManager::ServiceDescription {
SERVICE_SOCKET, /* path */
- "*" /* smackLabel label (not used, we rely on systemd) */
};
}
};
public:
struct ServiceDescription {
std::string serviceHandlerPath; // Path to file
- std::string smackLabel; // Smack label for socket
};
struct ConnectionID {
# @file CMakeLists.txt
#
-PKG_CHECK_MODULES(UNIT_TESTS_DEPS
- REQUIRED
+SET(UNIT_TESTS_DEP_LIST
dlog
gtest
libsystemd
- libsmack
cynara-client
cynara-creds-socket
cynara-admin
)
+IF (SMACK_ENABLED)
+ SET(UNIT_TESTS_DEP_LIST ${UNIT_TESTS_DEP_LIST} libsmack)
+ENDIF (SMACK_ENABLED)
+
+PKG_CHECK_MODULES(UNIT_TESTS_DEPS
+ REQUIRED
+ ${UNIT_TESTS_DEP_LIST}
+ )
+
IF(GCOV_BUILD)
# coverage data
SET(COVERAGE_BUILD_DIR
${CMAKE_CURRENT_SOURCE_DIR}/socket-manager-test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils-tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cynara-adm.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/privilege-tests.cpp
${PRJ_SRC_SERVER_PATH}/dl-loader.cpp
${PRJ_SRC_SERVER_PATH}/service.cpp
${PRJ_SRC_SERVER_PATH}/cynara.cpp
)
+IF (SMACK_ENABLED)
+ SET(UNIT_TESTS_SOURCES ${UNIT_TESTS_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/privilege-tests.cpp)
+ENDIF (SMACK_ENABLED)
+
SET_SOURCE_FILES_PROPERTIES(
${UNIT_TESTS_SOURCES}
PROPERTIES
SocketManager::ServiceDescription GetServiceDescription() override {
return SocketManager::ServiceDescription {
TEST_SERVICE_SOCKET, /* path */
- "*" /* smackLabel label (not used, we rely on systemd) */
};
}
TestService(std::shared_ptr<DLLoader> pluginHybrid) :
SocketManager::ServiceDescription GetServiceDescription() override {
return SocketManager::ServiceDescription {
TEST_SERVICE_SOCKET, /* path */
- "*" /* smackLabel label (not used, we rely on systemd) */
};
}
TestService(std::shared_ptr<DLLoader> pluginHybrid) :