From: Dmytro Lomtiev Date: Mon, 19 Mar 2018 11:46:25 +0000 (+0200) Subject: Daemon name was changed. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b336f4b52ebc55d8783f86ae508925f487ef2cf1;p=platform%2Fcore%2Fsecurity%2Fsuspicious-activity-monitor.git Daemon name was changed. --- diff --git a/device-agent/CMakeLists.txt b/device-agent/CMakeLists.txt index 64316c5..3227968 100644 --- a/device-agent/CMakeLists.txt +++ b/device-agent/CMakeLists.txt @@ -18,21 +18,25 @@ message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") INCLUDE(FindPkgConfig) -IF (NOT DEFINED SAMONITOR_CONFIG_FILE) - SET (SAMONITOR_CONFIG_FILE "samonitor.conf") +IF (NOT DEFINED DAEMON_APP_NAME) + SET (DAEMON_APP_NAME "sam-agent") ENDIF() -IF (NOT DEFINED SAMONITOR_CONFIG_DIR) - SET (SAMONITOR_CONFIG_DIR "/etc/samonitor") +IF (NOT DEFINED DAEMON_CONFIG_FILE) + SET (DAEMON_CONFIG_FILE "sam.conf") +ENDIF() + +IF (NOT DEFINED DAEMON_CONFIG_DIR) + SET (DAEMON_CONFIG_DIR "/etc/sam") ENDIF() if (NOT DEFINED LIBDIR) SET (LIBDIR ${LIB_INSTALL_DIR}) endif (NOT DEFINED LIBDIR) -if (NOT DEFINED TESTS_DIR) - SET (TESTS_DIR "/usr/apps/samonitor") -endif (NOT DEFINED TESTS_DIR) +if (NOT DEFINED BIN_DIR) + SET (BIN_DIR "/usr/apps/sam") +endif (NOT DEFINED BIN_DIR) pkg_check_modules(pkgs REQUIRED boost libcurl dpm dlog audit-trail) @@ -42,7 +46,7 @@ ENDFOREACH(flag) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DTB_LOG -D__TIZEN__ -DDPM_BUILD_${DPM_BUILD_TYPE} -DPROFILE_${BUILD_PROFILE} -DDATA_DIR=${DATA_DIR}") -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DSAMONITOR_CONFIG_FILE=${SAMONITOR_CONFIG_DIR}/${SAMONITOR_CONFIG_FILE}") +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DCONFIG_FILE_PATH=${DAEMON_CONFIG_DIR}/${DAEMON_CONFIG_FILE}") if (NOT DEFINED LIB_INCLUDE_DIR) SET(LIB_INCLUDE_DIR "/usr/include") @@ -61,7 +65,7 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11") add_subdirectory(utest) add_subdirectory(communication) -add_subdirectory(samonitor) +add_subdirectory(daemon) add_custom_target(runtests COMMAND utest diff --git a/device-agent/common/inc/samonitor_tag.h b/device-agent/common/inc/samonitor_tag.h index 18c62a4..047eeef 100644 --- a/device-agent/common/inc/samonitor_tag.h +++ b/device-agent/common/inc/samonitor_tag.h @@ -13,7 +13,7 @@ #define SA_MONITOR_TAG_H #ifndef TAG -# define TAG "SAMonitor" +# define TAG "SAM" #endif #endif // SA_MONITOR_TAG_H diff --git a/device-agent/communication/src/connection.cpp b/device-agent/communication/src/connection.cpp index bf961e9..819f710 100644 --- a/device-agent/communication/src/connection.cpp +++ b/device-agent/communication/src/connection.cpp @@ -46,7 +46,7 @@ int Connection::addEventListener(const std::string& type, EventListener* listene auto& where = listeners[type]; where.push_back(listener); active.emplace(id, std::make_pair(std::ref(where), listener)); - LOG_E(TAG, "Registered listener of type: %s", type.c_str()); + LOG_D(TAG, "Registered listener of type: %s", type.c_str()); return id; } diff --git a/device-agent/communication/src/settings.cpp b/device-agent/communication/src/settings.cpp index 88289e4..9944863 100644 --- a/device-agent/communication/src/settings.cpp +++ b/device-agent/communication/src/settings.cpp @@ -18,11 +18,11 @@ #include "samonitor_tag.h" #include "macro.h" -#if !defined(SAMONITOR_CONFIG_FILE) -# error "SAMONITOR_CONFIG_FILE must be defined" +#if !defined(CONFIG_FILE_PATH) +# error "CONFIG_FILE_PATH must be defined" #endif -#define CONFIG_FILE STRINGIFY(SAMONITOR_CONFIG_FILE) +#define CONFIG_FILE STRINGIFY(CONFIG_FILE_PATH) // Defaults namespace diff --git a/device-agent/samonitor/CMakeLists.txt b/device-agent/daemon/CMakeLists.txt similarity index 66% rename from device-agent/samonitor/CMakeLists.txt rename to device-agent/daemon/CMakeLists.txt index 9c36b8d..ab5642a 100644 --- a/device-agent/samonitor/CMakeLists.txt +++ b/device-agent/daemon/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required (VERSION 2.8) -get_filename_component(ProjectId ${CMAKE_CURRENT_SOURCE_DIR} NAME) -string(REPLACE " " "_" ProjectId ${ProjectId}) -project(${ProjectId} C CXX) +project(${DAEMON_APP_NAME} C CXX) include_directories( ../communication/inc @@ -44,9 +42,9 @@ else() message(FATAL_ERROR "systemd library not found") endif() -install(TARGETS ${PROJECT_NAME} DESTINATION ${TESTS_DIR}) -install(FILES samonitor.manifest DESTINATION ${MANIFESTDIR}) -install(FILES samonitor.service DESTINATION ${SERVICE_INSTALL_DIR}) -install(FILES default.conf DESTINATION ${SAMONITOR_CONFIG_DIR} RENAME ${SAMONITOR_CONFIG_FILE}) +install(TARGETS ${PROJECT_NAME} DESTINATION ${BIN_DIR}) +install(FILES ${PROJECT_NAME}.manifest DESTINATION ${MANIFESTDIR}) +install(FILES sam.service DESTINATION ${SERVICE_INSTALL_DIR}) +install(FILES default.conf DESTINATION ${DAEMON_CONFIG_DIR} RENAME ${DAEMON_CONFIG_FILE}) message(STATUS "Configuring: " ${ProjectId}) message(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS}) diff --git a/device-agent/samonitor/application_service.cpp b/device-agent/daemon/application_service.cpp similarity index 100% rename from device-agent/samonitor/application_service.cpp rename to device-agent/daemon/application_service.cpp diff --git a/device-agent/samonitor/application_service.h b/device-agent/daemon/application_service.h similarity index 100% rename from device-agent/samonitor/application_service.h rename to device-agent/daemon/application_service.h diff --git a/device-agent/samonitor/audit_trail_client.cpp b/device-agent/daemon/audit_trail_client.cpp similarity index 100% rename from device-agent/samonitor/audit_trail_client.cpp rename to device-agent/daemon/audit_trail_client.cpp diff --git a/device-agent/samonitor/audit_trail_client.h b/device-agent/daemon/audit_trail_client.h similarity index 100% rename from device-agent/samonitor/audit_trail_client.h rename to device-agent/daemon/audit_trail_client.h diff --git a/device-agent/samonitor/commandhandler.h b/device-agent/daemon/commandhandler.h similarity index 100% rename from device-agent/samonitor/commandhandler.h rename to device-agent/daemon/commandhandler.h diff --git a/device-agent/samonitor/default.conf b/device-agent/daemon/default.conf similarity index 100% rename from device-agent/samonitor/default.conf rename to device-agent/daemon/default.conf diff --git a/device-agent/samonitor/device_list.h b/device-agent/daemon/device_list.h similarity index 100% rename from device-agent/samonitor/device_list.h rename to device-agent/daemon/device_list.h diff --git a/device-agent/samonitor/dpm/common_enforce.cpp b/device-agent/daemon/dpm/common_enforce.cpp similarity index 100% rename from device-agent/samonitor/dpm/common_enforce.cpp rename to device-agent/daemon/dpm/common_enforce.cpp diff --git a/device-agent/samonitor/dpm/common_enforce.h b/device-agent/daemon/dpm/common_enforce.h similarity index 100% rename from device-agent/samonitor/dpm/common_enforce.h rename to device-agent/daemon/dpm/common_enforce.h diff --git a/device-agent/samonitor/dpm/dpm_api_mapper.cpp b/device-agent/daemon/dpm/dpm_api_mapper.cpp similarity index 100% rename from device-agent/samonitor/dpm/dpm_api_mapper.cpp rename to device-agent/daemon/dpm/dpm_api_mapper.cpp diff --git a/device-agent/samonitor/dpm/dpm_api_mapper.h b/device-agent/daemon/dpm/dpm_api_mapper.h similarity index 100% rename from device-agent/samonitor/dpm/dpm_api_mapper.h rename to device-agent/daemon/dpm/dpm_api_mapper.h diff --git a/device-agent/samonitor/dpm/i_policy_group_enforce.h b/device-agent/daemon/dpm/i_policy_group_enforce.h similarity index 100% rename from device-agent/samonitor/dpm/i_policy_group_enforce.h rename to device-agent/daemon/dpm/i_policy_group_enforce.h diff --git a/device-agent/samonitor/dpm/policy_enforce.cpp b/device-agent/daemon/dpm/policy_enforce.cpp similarity index 100% rename from device-agent/samonitor/dpm/policy_enforce.cpp rename to device-agent/daemon/dpm/policy_enforce.cpp diff --git a/device-agent/samonitor/dpm/policy_enforce.h b/device-agent/daemon/dpm/policy_enforce.h similarity index 100% rename from device-agent/samonitor/dpm/policy_enforce.h rename to device-agent/daemon/dpm/policy_enforce.h diff --git a/device-agent/samonitor/dpm/tvext_enforce.cpp b/device-agent/daemon/dpm/tvext_enforce.cpp similarity index 100% rename from device-agent/samonitor/dpm/tvext_enforce.cpp rename to device-agent/daemon/dpm/tvext_enforce.cpp diff --git a/device-agent/samonitor/dpm/tvext_enforce.h b/device-agent/daemon/dpm/tvext_enforce.h similarity index 100% rename from device-agent/samonitor/dpm/tvext_enforce.h rename to device-agent/daemon/dpm/tvext_enforce.h diff --git a/device-agent/samonitor/icommandhandler.h b/device-agent/daemon/icommandhandler.h similarity index 100% rename from device-agent/samonitor/icommandhandler.h rename to device-agent/daemon/icommandhandler.h diff --git a/device-agent/samonitor/ireporter.h b/device-agent/daemon/ireporter.h similarity index 100% rename from device-agent/samonitor/ireporter.h rename to device-agent/daemon/ireporter.h diff --git a/device-agent/samonitor/main.cpp b/device-agent/daemon/main.cpp similarity index 97% rename from device-agent/samonitor/main.cpp rename to device-agent/daemon/main.cpp index de4ddcb..1540f1e 100644 --- a/device-agent/samonitor/main.cpp +++ b/device-agent/daemon/main.cpp @@ -5,7 +5,7 @@ */ /** * @file main.cpp - * @brief nmdaemon main entry point + * @brief daemon main entry point * @date Created Apr 18, 2017 * @author Mail to: Iurii Metelytsia, i.metelytsia@samsung.com * @author Mail to: Andriy Gudz, a.gudz@samsung.com @@ -32,7 +32,7 @@ #include "utils.h" #include "systemdwrapper.h" -#define TAG "[NMDAEMON] " +#include "samonitor_tag.h" using namespace NMD; diff --git a/device-agent/samonitor/main_thread.cpp b/device-agent/daemon/main_thread.cpp similarity index 100% rename from device-agent/samonitor/main_thread.cpp rename to device-agent/daemon/main_thread.cpp diff --git a/device-agent/samonitor/main_thread.h b/device-agent/daemon/main_thread.h similarity index 100% rename from device-agent/samonitor/main_thread.h rename to device-agent/daemon/main_thread.h diff --git a/device-agent/samonitor/policyhandler.cpp b/device-agent/daemon/policyhandler.cpp similarity index 100% rename from device-agent/samonitor/policyhandler.cpp rename to device-agent/daemon/policyhandler.cpp diff --git a/device-agent/samonitor/policyhandler.h b/device-agent/daemon/policyhandler.h similarity index 100% rename from device-agent/samonitor/policyhandler.h rename to device-agent/daemon/policyhandler.h diff --git a/device-agent/samonitor/proxythread.h b/device-agent/daemon/proxythread.h similarity index 100% rename from device-agent/samonitor/proxythread.h rename to device-agent/daemon/proxythread.h diff --git a/device-agent/samonitor/report_stub.cpp b/device-agent/daemon/report_stub.cpp similarity index 100% rename from device-agent/samonitor/report_stub.cpp rename to device-agent/daemon/report_stub.cpp diff --git a/device-agent/samonitor/report_stub.h b/device-agent/daemon/report_stub.h similarity index 100% rename from device-agent/samonitor/report_stub.h rename to device-agent/daemon/report_stub.h diff --git a/device-agent/samonitor/reportadapter.cpp b/device-agent/daemon/reportadapter.cpp similarity index 100% rename from device-agent/samonitor/reportadapter.cpp rename to device-agent/daemon/reportadapter.cpp diff --git a/device-agent/samonitor/reportadapter.h b/device-agent/daemon/reportadapter.h similarity index 100% rename from device-agent/samonitor/reportadapter.h rename to device-agent/daemon/reportadapter.h diff --git a/device-agent/samonitor/samonitor.manifest b/device-agent/daemon/sam-agent.manifest similarity index 100% rename from device-agent/samonitor/samonitor.manifest rename to device-agent/daemon/sam-agent.manifest diff --git a/device-agent/samonitor/samonitor.service b/device-agent/daemon/sam.service similarity index 72% rename from device-agent/samonitor/samonitor.service rename to device-agent/daemon/sam.service index 1eaa52a..acabe8e 100644 --- a/device-agent/samonitor/samonitor.service +++ b/device-agent/daemon/sam.service @@ -1,10 +1,10 @@ [Unit] -Description=samonitor +Description=Suspisious activity monitor After=syslog.target network.target [Service] -ExecStart=/usr/apps/samonitor/samonitor +ExecStart=/usr/apps/sam/sam-agent Type=notify WatchdogSec=5s KillMode=process diff --git a/device-agent/samonitor/settingshandler.cpp b/device-agent/daemon/settingshandler.cpp similarity index 100% rename from device-agent/samonitor/settingshandler.cpp rename to device-agent/daemon/settingshandler.cpp diff --git a/device-agent/samonitor/settingshandler.h b/device-agent/daemon/settingshandler.h similarity index 100% rename from device-agent/samonitor/settingshandler.h rename to device-agent/daemon/settingshandler.h diff --git a/device-agent/samonitor/systemdwrapper.cpp b/device-agent/daemon/systemdwrapper.cpp similarity index 100% rename from device-agent/samonitor/systemdwrapper.cpp rename to device-agent/daemon/systemdwrapper.cpp diff --git a/device-agent/samonitor/systemdwrapper.h b/device-agent/daemon/systemdwrapper.h similarity index 100% rename from device-agent/samonitor/systemdwrapper.h rename to device-agent/daemon/systemdwrapper.h diff --git a/device-agent/samonitor/thread_base.cpp b/device-agent/daemon/thread_base.cpp similarity index 100% rename from device-agent/samonitor/thread_base.cpp rename to device-agent/daemon/thread_base.cpp diff --git a/device-agent/samonitor/thread_base.h b/device-agent/daemon/thread_base.h similarity index 100% rename from device-agent/samonitor/thread_base.h rename to device-agent/daemon/thread_base.h diff --git a/device-agent/samonitor/utils.cpp b/device-agent/daemon/utils.cpp similarity index 100% rename from device-agent/samonitor/utils.cpp rename to device-agent/daemon/utils.cpp diff --git a/device-agent/samonitor/utils.h b/device-agent/daemon/utils.h similarity index 100% rename from device-agent/samonitor/utils.h rename to device-agent/daemon/utils.h diff --git a/device-agent/packaging/samonitor.spec b/device-agent/packaging/sam.spec similarity index 71% rename from device-agent/packaging/samonitor.spec rename to device-agent/packaging/sam.spec index a37085f..c0076ca 100644 --- a/device-agent/packaging/samonitor.spec +++ b/device-agent/packaging/sam.spec @@ -1,4 +1,4 @@ -Name: samonitor +Name: sam Version: 1.0.0 Release: 9 Summary: TODO @@ -31,15 +31,16 @@ BuildRequires: python-xml -%define _app_name samonitor -%define _app_dir /usr/apps/%{_app_name} +%define _project_name sam +%define _app_name %{_project_name}-agent +%define _app_dir /usr/apps/%{_project_name} %define _manifestdir /usr/share/packages %define _service_dir /usr/lib/systemd/system %define _service_symlink_dir /etc/systemd/system/multi-user.target.wants %define _lib_include_dir /usr/include -%define _conf_dir /etc/%{_app_name} -%define _conf_file %{_app_name}.conf -%define _data_dir /opt/data/%{_app_name} +%define _conf_dir /etc/%{_project_name} +%define _conf_file %{_project_name}.conf +%define _data_dir /opt/data/%{_project_name} %if ("%{GTEST_TYPE}" == "mock") %define _gtest_lib gmock_main @@ -60,14 +61,16 @@ Suspicious Activity Monitor cmake -H./ -B./build-gbs \ -DLIB_INSTALL_DIR=%{_libdir} \ -DMANIFESTDIR=%{_manifestdir} \ - -DTESTS_DIR=%{_app_dir} \ + -DBIN_DIR=%{_app_dir} \ -DGTEST_LIB=%{_gtest_lib} \ -DLIB_INCLUDE_DIR=%{_lib_include_dir} \ -DSERVICE_INSTALL_DIR=%{_service_dir} \ - -DNWMANAGER_CONFIG_FILE=%{_conf_file} \ - -DNWMANAGER_CONFIG_DIR=%{_conf_dir} \ + -DDAEMON_CONFIG_FILE=%{_conf_file} \ + -DDAEMON_CONFIG_DIR=%{_conf_dir} \ + -DDAEMON_APP_NAME=%{_app_name} \ -DCMAKE_BUILD_TYPE=%{build_type} \ -DDPM_BUILD_TYPE=%{dpm_type} \ + -DDAEMON_NAME=%{_app_name} \ -DDATA_DIR=%{_data_dir} \ #eol @@ -88,30 +91,30 @@ rm -rf %{buildroot} # Suspicious Activity Monitor ############################################## -%package samonitor +%package sam Summary: Suspicious Activity Monitor -Provides: samonitor -%description samonitor +Provides: sam +%description sam Suspicious Activity Monitor daemon -%post samonitor +%post sam mkdir -p %{_data_dir} -ln -sf %{_service_dir}/samonitor.service %{_service_symlink_dir}/samonitor.service +ln -sf %{_service_dir}/%{_project_name}.service %{_service_symlink_dir}/%{_project_name}.service systemctl daemon-reload -dpm-admin-cli -r samonitor -u owner -dpm-admin-cli -r %{_app_dir}/samonitor -u owner +dpm-admin-cli -r %{_app_name} -u owner +dpm-admin-cli -r %{_app_dir}/%{_app_name} -u owner systemctl restart device-policy-manager -systemctl restart samonitor +systemctl restart %{_project_name} -%postun samonitor -systemctl stop samonitor +%postun sam +systemctl stop %{_project_name} rm -r %{_data_dir} -%files samonitor -%manifest %{_manifestdir}/samonitor.manifest -%attr(0755,root,root) %{_app_dir}/samonitor -%attr(0664,root,root) %{_service_dir}/samonitor.service +%files sam +%manifest %{_manifestdir}/%{_app_name}.manifest +%attr(0755,root,root) %{_app_dir}/%{_app_name} +%attr(0664,root,root) %{_service_dir}/%{_project_name}.service %attr(0664,root,root) %{_conf_dir}/%{_conf_file} diff --git a/device-agent/samonitor.manifest.in b/device-agent/sam-agent.manifest.in similarity index 100% rename from device-agent/samonitor.manifest.in rename to device-agent/sam-agent.manifest.in diff --git a/device-agent/scripts/deploy.sh b/device-agent/scripts/deploy.sh index 60882d2..b786b6c 100755 --- a/device-agent/scripts/deploy.sh +++ b/device-agent/scripts/deploy.sh @@ -63,8 +63,8 @@ GBS_RPMS_DIR=~/gbs_root_${PROFILE_NAME}/local/repos/${PROFILE_NAME}/${TARGET_ARC sdb root on sdb shell mount -o remount,rw / -sdb shell "rpm -e --nodeps \$(rpm -qa 'nwmanager*')" +sdb shell "rpm -e --nodeps \$(rpm -qa 'sam-*')" sdb shell rm -rf /tmp/rpms/ sdb shell mkdir /tmp/rpms/ -sdb push ${GBS_RPMS_DIR}/samonitor-* /tmp/rpms/ +sdb push ${GBS_RPMS_DIR}/sam-* /tmp/rpms/ sdb shell "rpm -ivh --nodeps --force /tmp/rpms/*.rpm" diff --git a/device-agent/scripts/ssh_deploy.sh b/device-agent/scripts/ssh_deploy.sh index c121fc4..a7ad496 100755 --- a/device-agent/scripts/ssh_deploy.sh +++ b/device-agent/scripts/ssh_deploy.sh @@ -114,8 +114,8 @@ TARGET_HOST="root@${TARGET_IP}" PASS="sshpass -p ${SSH_PASSWORD}" ${PASS} ssh ${TARGET_HOST} "mount -o remount,rw /" -${PASS} ssh ${TARGET_HOST} "rpm -e --nodeps \$(rpm -qa 'samonitor*')" +${PASS} ssh ${TARGET_HOST} "rpm -e --nodeps \$(rpm -qa 'sam-*')" ${PASS} ssh ${TARGET_HOST} "rm -r /tmp/rpms/" ${PASS} ssh ${TARGET_HOST} "mkdir /tmp/rpms/" -${PASS} scp ${GBS_RPMS_DIR}/samonitor-* ${TARGET_HOST}:/tmp/rpms/ +${PASS} scp ${GBS_RPMS_DIR}/sam-* ${TARGET_HOST}:/tmp/rpms/ ${PASS} ssh ${TARGET_HOST} "rpm -Uvih --nodeps --force /tmp/rpms/*.rpm" diff --git a/device-agent/utest/CMakeLists.txt b/device-agent/utest/CMakeLists.txt index 67d71f7..46f1f30 100644 --- a/device-agent/utest/CMakeLists.txt +++ b/device-agent/utest/CMakeLists.txt @@ -13,17 +13,17 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wp,-U_FORTIFY_SOURCE") include_directories ( mock ../communication/inc - ../samonitor - ../samonitor/dpm + ../daemon + ../daemon/dpm ../. ) include_directories(BEFORE ../mock) -FILE(GLOB SRCS *.cpp ../samonitor/*.cpp ../samonitor/dpm/*.cpp mock/*.cpp) +FILE(GLOB SRCS *.cpp ../daemon/*.cpp ../daemon/dpm/*.cpp mock/*.cpp) -FILE(GLOB DAEMON_MAIN ../samonitor/main.cpp) -FILE(GLOB DAEMON_MAIN_THREAD ../samonitor/main_thread.cpp) +FILE(GLOB DAEMON_MAIN ../daemon/main.cpp) +FILE(GLOB DAEMON_MAIN_THREAD ../daemon/main_thread.cpp) list(REMOVE_ITEM SRCS ${DAEMON_MAIN}) list(REMOVE_ITEM SRCS ${DAEMON_MAIN_THREAD}) @@ -53,7 +53,7 @@ else() target_link_libraries(${PROJECT_NAME} systemd) endif() -install(TARGETS ${PROJECT_NAME} DESTINATION ${TESTS_DIR}) +install(TARGETS ${PROJECT_NAME} DESTINATION ${BIN_DIR}) install(FILES tests.manifest DESTINATION ${MANIFESTDIR}) message(STATUS "Configuring: " ${ProjectId})