%{_unitdir}/audit-trail.service
%{_unitdir}/multi-user.target.wants/audit-trail.service
%attr(700,root,root) %{_sbindir}/audit-trail-admin-cli
-%attr(700,root,root) %{_sbindir}/audit-trail-send-test
-%attr(700,root,root) %{_sbindir}/audit-trail-speed-test
%prep
%setup -q
%{_libdir}/libaudit-trail.so
%{_includedir}/audit-trail
%{_libdir}/pkgconfig/audit-trail.pc
+
+## Audit Trail Test Package ################################################
+%package -n audit-trail-tests
+Summary: Testcases for Tizen audit daemon
+Group: Security/Testing
+BuildRequires: pkgconfig(libtzplatform-config)
+Requires: %{name} = %{version}-%{release}
+
+%description -n audit-trail-tests
+The audit-trail-test package contains the testcases needed to test audit functions
+
+%files -n audit-trail-tests
+%manifest audit-trail.manifest
+%defattr(644,root,root,755)
+%attr(700,root,root) %{_sbindir}/audit-trail-send-test
+%attr(700,root,root) %{_sbindir}/audit-trail-speed-test
# limitations under the License.
#
SET(AUDIT_TRAIL_CLI ${AUDIT_TRAIL_TOOLS}/cli)
+SET(AUDIT_TRAIL_TEST ${AUDIT_TRAIL_TOOLS}/tests)
ADD_SUBDIRECTORY(${AUDIT_TRAIL_CLI})
+ADD_SUBDIRECTORY(${AUDIT_TRAIL_TEST})
#
FILE(GLOB CLI_SRCS audit-trail-admin-cli.cpp)
-FILE(GLOB SEND_TEST_SRCS audit-trail-send-test.cpp)
-FILE(GLOB SPEED_TEST_SRCS audit-trail-speed-test.cpp)
SET(CLI_NAME ${PROJECT_NAME}-admin-cli)
-SET(SEND_TEST_NAME ${PROJECT_NAME}-send-test)
-SET(SPEED_TEST_NAME ${PROJECT_NAME}-speed-test)
ADD_EXECUTABLE(${CLI_NAME} ${CLI_SRCS})
-ADD_EXECUTABLE(${SEND_TEST_NAME} ${SEND_TEST_SRCS})
-ADD_EXECUTABLE(${SPEED_TEST_NAME} ${SPEED_TEST_SRCS})
SET_TARGET_PROPERTIES(${CLI_NAME} PROPERTIES PREFIX ""
COMPILE_FLAGS "-fPIE"
LINK_FLAGS "-pie"
)
-SET_TARGET_PROPERTIES(${SEND_TEST_NAME} PROPERTIES PREFIX ""
- COMPILE_FLAGS "-fPIE"
- LINK_FLAGS "-pie"
-)
-SET_TARGET_PROPERTIES(${SPEED_TEST_NAME} PROPERTIES PREFIX ""
- COMPILE_FLAGS "-fPIE"
- LINK_FLAGS "-pie"
-)
PKG_CHECK_MODULES(CLI_DEPS REQUIRED
klay
INCLUDE_DIRECTORIES(SYSTEM ${CLI_DEPS_INCLUDE_DIRS} ${AUDIT_TRAIL_LIB})
TARGET_LINK_LIBRARIES(${CLI_NAME} ${CLI_DEPS_LIBRARIES} ${PROJECT_NAME} audit-trail)
-TARGET_LINK_LIBRARIES(${SPEED_TEST_NAME} ${CLI_DEPS_LIBRARIES} ${PROJECT_NAME} audit-trail)
INSTALL(TARGETS ${CLI_NAME} DESTINATION sbin)
-INSTALL(TARGETS ${SEND_TEST_NAME} DESTINATION sbin)
-INSTALL(TARGETS ${SPEED_TEST_NAME} DESTINATION sbin)
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @file
- * @brief CLI tool to test sending audit messages
- */
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/socket.h>
-#include <linux/netlink.h>
-
-#include <string>
-#include <cstring>
-#include <iostream>
-
-
-extern char** environ;
-
-static inline void usage(const std::string name)
-{
- std::cout << "Usage: " << name << " <audit number> <message>" << std::endl
- << std::endl;
-}
-
-int main(int argc, char* argv[])
-{
- if (argc != 3) {
- usage(argv[0]);
- return EXIT_SUCCESS;
- }
-
- int type = std::stoi(std::string(argv[1]));
- std::string message(argv[2]);
- int fd;
-
- fd = ::socket(PF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
- if (fd < 0) {
- std::cerr << "Failed to open a netlink socket" << std::endl;
- return EXIT_FAILURE;
- }
-
- if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
- ::close(fd);
- std::cerr << "Failed to set FD_CLOEXEC" << std::endl;
- return EXIT_FAILURE;
- }
-
- struct sockaddr_nl addr;
- int ret;
-
- ::memset(&addr, 0, sizeof(addr));
- addr.nl_family = AF_NETLINK;
- addr.nl_pid = 0;
- addr.nl_groups = 0;
-
- char buf[NLMSG_SPACE(message.size())];
- struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
- ::memset(buf, 0, sizeof(buf));
-
- nlh->nlmsg_len = sizeof(buf);
- nlh->nlmsg_type = type;
- nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
- nlh->nlmsg_seq = 0;
-
- ::memcpy(NLMSG_DATA(buf), message.c_str(), message.size());
-
- do {
- ret = ::sendto(fd, buf, sizeof(buf), 0,
- (struct sockaddr*)&addr, sizeof(addr));
- } while (ret < 0 && errno == EINTR);
-
- if (ret < 0) {
- ::close(fd);
- std::cerr << "Failed to send a netlink packet" << std::endl;
- return EXIT_FAILURE;
- }
-
- ::close(fd);
- return EXIT_SUCCESS;
-}
+++ /dev/null
-/*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @file
- * @brief CLI tool to test a speed of sending and receiving
- */
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <linux/netlink.h>
-#include <audit-trail/user.h>
-
-#include <string>
-#include <cstring>
-#include <iostream>
-
-#define COUNT 10
-
-extern char** environ;
-struct timeval begin_time, end_time;
-volatile bool end;
-
-long long total_time = 0;
-
-void logCb(void* log, void *userData)
-{
- gettimeofday(&end_time, NULL);
- end = true;
-}
-
-int main(int argc, char* argv[])
-{
- int type = 1111;
- std::string message("test");
- int fd;
-
- fd = ::socket(PF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
- if (fd < 0) {
- std::cerr << "Failed to open a netlink socket" << std::endl;
- return EXIT_FAILURE;
- }
-
- if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
- ::close(fd);
- std::cerr << "Failed to set FD_CLOEXEC" << std::endl;
- return EXIT_FAILURE;
- }
-
- struct sockaddr_nl addr;
- int ret;
-
- ::memset(&addr, 0, sizeof(addr));
- addr.nl_family = AF_NETLINK;
- addr.nl_pid = 0;
- addr.nl_groups = 0;
-
- char buf[NLMSG_SPACE(message.size())];
- struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
- ::memset(buf, 0, sizeof(buf));
-
- nlh->nlmsg_len = sizeof(buf);
- nlh->nlmsg_type = type;
- nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
- nlh->nlmsg_seq = 0;
-
- ::memcpy(NLMSG_DATA(buf), message.c_str(), message.size());
-
- audit_trail_h auditTrail;
- audit_trail_create(&auditTrail);
- audit_trail_enable_user(auditTrail, true);
-
- audit_trail_add_user_cb(auditTrail, logCb, NULL, &ret);
-
- for (int i = 0; i < COUNT ; i++) {
- end = false;
- gettimeofday(&begin_time, NULL);
-
- do {
- ret = ::sendto(fd, buf, sizeof(buf), 0,
- (struct sockaddr*)&addr, sizeof(addr));
- } while (ret < 0 && errno == EINTR);
-
- while (!end);
-
- total_time += end_time.tv_usec - begin_time.tv_usec;
- }
-
- std::cout << total_time / COUNT << "us" << std::endl;
-
- if (ret < 0) {
- ::close(fd);
- std::cerr << "Failed to send a netlink packet" << std::endl;
- return EXIT_FAILURE;
- }
-
- ::close(fd);
- audit_trail_destroy(auditTrail);
-
- return EXIT_SUCCESS;
-}
--- /dev/null
+#
+# Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+FILE(GLOB SEND_SRCS send.cpp)
+FILE(GLOB SPEED_SRCS speed.cpp)
+
+SET(SEND_NAME ${PROJECT_NAME}-send-test)
+SET(SPEED_NAME ${PROJECT_NAME}-speed-test)
+
+ADD_EXECUTABLE(${SEND_NAME} ${SEND_SRCS})
+ADD_EXECUTABLE(${SPEED_NAME} ${SPEED_SRCS})
+
+
+SET_TARGET_PROPERTIES(${SEND_NAME} PROPERTIES PREFIX ""
+ COMPILE_FLAGS "-fPIE"
+ LINK_FLAGS "-pie"
+)
+SET_TARGET_PROPERTIES(${SPEED_NAME} PROPERTIES PREFIX ""
+ COMPILE_FLAGS "-fPIE"
+ LINK_FLAGS "-pie"
+)
+
+PKG_CHECK_MODULES(CLI_DEPS REQUIRED
+ klay
+ glib-2.0
+)
+
+INCLUDE_DIRECTORIES(SYSTEM ${CLI_DEPS_INCLUDE_DIRS} ${AUDIT_TRAIL_LIB})
+TARGET_LINK_LIBRARIES(${SPEED_NAME} ${CLI_DEPS_LIBRARIES} ${PROJECT_NAME} audit-trail)
+
+INSTALL(TARGETS ${SEND_NAME} DESTINATION sbin)
+INSTALL(TARGETS ${SPEED_NAME} DESTINATION sbin)
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file
+ * @brief CLI tool to test sending audit messages
+ */
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+
+#include <string>
+#include <cstring>
+#include <iostream>
+
+
+extern char** environ;
+
+static inline void usage(const std::string name)
+{
+ std::cout << "Usage: " << name << " <audit number> <message>" << std::endl
+ << std::endl;
+}
+
+int main(int argc, char* argv[])
+{
+ if (argc != 3) {
+ usage(argv[0]);
+ return EXIT_SUCCESS;
+ }
+
+ int type = std::stoi(std::string(argv[1]));
+ std::string message(argv[2]);
+ int fd;
+
+ fd = ::socket(PF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
+ if (fd < 0) {
+ std::cerr << "Failed to open a netlink socket" << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
+ ::close(fd);
+ std::cerr << "Failed to set FD_CLOEXEC" << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ struct sockaddr_nl addr;
+ int ret;
+
+ ::memset(&addr, 0, sizeof(addr));
+ addr.nl_family = AF_NETLINK;
+ addr.nl_pid = 0;
+ addr.nl_groups = 0;
+
+ char buf[NLMSG_SPACE(message.size())];
+ struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
+ ::memset(buf, 0, sizeof(buf));
+
+ nlh->nlmsg_len = sizeof(buf);
+ nlh->nlmsg_type = type;
+ nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
+ nlh->nlmsg_seq = 0;
+
+ ::memcpy(NLMSG_DATA(buf), message.c_str(), message.size());
+
+ do {
+ ret = ::sendto(fd, buf, sizeof(buf), 0,
+ (struct sockaddr*)&addr, sizeof(addr));
+ } while (ret < 0 && errno == EINTR);
+
+ if (ret < 0) {
+ ::close(fd);
+ std::cerr << "Failed to send a netlink packet" << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ ::close(fd);
+ return EXIT_SUCCESS;
+}
--- /dev/null
+/*
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file
+ * @brief CLI tool to test a speed of sending and receiving
+ */
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <audit-trail/user.h>
+
+#include <string>
+#include <cstring>
+#include <iostream>
+
+#define COUNT 10
+
+extern char** environ;
+struct timeval begin_time, end_time;
+volatile bool end;
+
+long long total_time = 0;
+
+void logCb(void* log, void *userData)
+{
+ gettimeofday(&end_time, NULL);
+ end = true;
+}
+
+int main(int argc, char* argv[])
+{
+ int type = 1111;
+ std::string message("test");
+ int fd;
+
+ fd = ::socket(PF_NETLINK, SOCK_RAW, NETLINK_AUDIT);
+ if (fd < 0) {
+ std::cerr << "Failed to open a netlink socket" << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ if (::fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
+ ::close(fd);
+ std::cerr << "Failed to set FD_CLOEXEC" << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ struct sockaddr_nl addr;
+ int ret;
+
+ ::memset(&addr, 0, sizeof(addr));
+ addr.nl_family = AF_NETLINK;
+ addr.nl_pid = 0;
+ addr.nl_groups = 0;
+
+ char buf[NLMSG_SPACE(message.size())];
+ struct nlmsghdr *nlh = (struct nlmsghdr *)buf;
+ ::memset(buf, 0, sizeof(buf));
+
+ nlh->nlmsg_len = sizeof(buf);
+ nlh->nlmsg_type = type;
+ nlh->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK;
+ nlh->nlmsg_seq = 0;
+
+ ::memcpy(NLMSG_DATA(buf), message.c_str(), message.size());
+
+ audit_trail_h auditTrail;
+ audit_trail_create(&auditTrail);
+ audit_trail_enable_user(auditTrail, true);
+
+ audit_trail_add_user_cb(auditTrail, logCb, NULL, &ret);
+
+ for (int i = 0; i < COUNT ; i++) {
+ end = false;
+ gettimeofday(&begin_time, NULL);
+
+ do {
+ ret = ::sendto(fd, buf, sizeof(buf), 0,
+ (struct sockaddr*)&addr, sizeof(addr));
+ } while (ret < 0 && errno == EINTR);
+
+ while (!end);
+
+ total_time += end_time.tv_usec - begin_time.tv_usec;
+ }
+
+ std::cout << total_time / COUNT << "us" << std::endl;
+
+ if (ret < 0) {
+ ::close(fd);
+ std::cerr << "Failed to send a netlink packet" << std::endl;
+ return EXIT_FAILURE;
+ }
+
+ ::close(fd);
+ audit_trail_destroy(auditTrail);
+
+ return EXIT_SUCCESS;
+}