#include <access_provider.h>
#include "tests_common.h"
#include <summary_collector.h>
-
+#include <memory.h>
#define PROPER_COOKIE_SIZE 20
-/**
- * Unique_ptr typedef for NOSMACK version of tc06 test
- */
-void closesockfdptr(int* sockfd_ptr)
-{
- close(*sockfd_ptr);
-}
-typedef std::unique_ptr<int, std::function<void(int*)> > SockFDUniquePtr;
RUNNER_TEST_GROUP_INIT(SECURITY_SERVER_TESTS_CLIENT_SMACK)
int sockfd = create_new_socket();
RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed");
- SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
+ SockUniquePtr sockfd_ptr(&sockfd);
label = security_server_get_smacklabel_sockfd(sockfd);
RUNNER_ASSERT_MSG_BT(label != NULL, "security_server_get_smacklabel_sockfd failed");
int sockfd = connect_to_testserver();
RUNNER_ASSERT_MSG_BT(sockfd >= 0, "connect_to_testserver() failed");
- SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
+ SockUniquePtr sockfd_ptr(&sockfd);
label = security_server_get_smacklabel_sockfd(sockfd);
RUNNER_ASSERT_MSG_BT(label != NULL, "security_server_get_smacklabel_sockfd failed");
int sockfd = create_new_socket();
RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed");
- SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
+ SockUniquePtr sockfd_ptr(&sockfd);
RUNNER_ASSERT_MSG_BT(0 == smack_set_label_for_self(subject_label), "child label " << subject_label << " not set");
int sockfd = create_new_socket();
RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed");
- SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
+ SockUniquePtr sockfd_ptr(&sockfd);
//check if get_smacklabel_sockfd works correctly
label = security_server_get_smacklabel_sockfd(sockfd);
int sockfd = connect_to_testserver();
RUNNER_ASSERT_MSG_BT(sockfd >= 0, "Failed to connect to server.");
- SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
+ SockUniquePtr sockfd_ptr(&sockfd);
label = security_server_get_smacklabel_sockfd(sockfd);
RUNNER_ASSERT_MSG_BT(label != NULL, "get_smacklabel_sockfd failed.");
int sockfd = create_new_socket();
RUNNER_ASSERT_MSG_BT(sockfd >= 0, "create_new_socket() failed");
- SockFDUniquePtr sockfd_ptr(&sockfd, closesockfdptr);
+ SockUniquePtr sockfd_ptr(&sockfd);
//Drop privileges
RUNNER_ASSERT_MSG_BT(drop_root_privileges() == 0, "uid = " << getuid());
//Request cookie from SS
res = security_server_request_cookie(cookie, cookie_size);
- std::unique_ptr<char, std::function<void(char*)> > cookie_ptr(cookie, free);
+ CookieUniquePtr cookie_ptr(cookie);
cookie = NULL;
RUNNER_ASSERT_MSG_BT(res == SECURITY_SERVER_API_SUCCESS,
"Error in requesting cookie from security-server. Result: " << res);