const time_t end_date, privacy_guard_client_privacy_count_of_package_cb callback, void *user_data)
{
if (user_id < 0 || start_date > end_date || start_date <= 0) {
- PG_LOGE("Invalid parameters.");
+ PG_LOGE("Invalid parameters. user id: [%d], start date: [%d], end date: [%d]", user_id, start_date, end_date);
return PRIV_GUARD_ERROR_INVALID_PARAMETER;
}
#define PRIVACY_DB_PATH tzplatform_mkpath(TZ_SYS_DB,".privacy_guard.db")
+//#define CYNARA_BUFFER_SIZE 1024
+#define CYNARA_BUFFER_SIZE 10
+
typedef struct _privacy_data_s {
char *privacy_id;
int monitor_policy;
int monitor_policy;
} package_data_s;
-
static const std::string SERVER_ADDRESS ("/tmp/privacy_guard_server");
static const std::string DBUS_PATH("/privacy_guard/dbus_notification");
static const std::string DBUS_SIGNAL_INTERFACE("org.tizen.privacy_guard.signal");
Description=Privacy Guard Server
[Service]
-User=system
-Group=system
+User=security_fw
+Group=security_fw
Type=simple
ExecStart=/usr/bin/privacy-guard-server
Sockets=privacy-guard-server.socket
Description=Privacy Guard Socket
[Socket]
-SocketUser=system
-SocketGroup=system
+SocketUser=security_fw
+SocketGroup=security_fw
ListenStream=/tmp/privacy_guard_server
SocketMode=0777
Name: privacy-guard-server
-Version: 0.0.1
+Version: 0.0.5
Release: 1
License: Apache-2.0
Summary: Privacy Management
SQL=".read ${TZ_SYS_BIN}/"$name"_db.sql"
sqlite3 ${TZ_SYS_DB}/.$name.db "$SQL"
touch ${TZ_SYS_DB}/.$name.db-journal
- chown system:system ${TZ_SYS_DB}/.$name.db
- chown system:system ${TZ_SYS_DB}/.$name.db-journal
+ chown security_fw:security_fw ${TZ_SYS_DB}/.$name.db
+ chown security_fw:security_fw ${TZ_SYS_DB}/.$name.db-journal
chmod 666 ${TZ_SYS_DB}/.$name.db
chmod 666 ${TZ_SYS_DB}/.$name.db-journal
done
INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info capi-system-info libtzplatform-config security-privilege-manager cynara-monitor)
+#pkg_check_modules(pkgs REQUIRED dlog sqlite3 dbus-1 dbus-glib-1 db-util pkgmgr-info capi-system-info libtzplatform-config security-privilege-manager)
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
${dbus_include_dir}
)
-SET(PRIVACY_GUARD_SERVER_SOURCES
+SET(PRIVACY_GUARD_SERVER_SOURCES
${common_src_dir}/SocketConnection.cpp
${common_src_dir}/SocketStream.cpp
- ${common_src_dir}/PrivacyIdInfo.cpp
+ ${common_src_dir}/PrivacyIdInfo.cpp
${server_src_dir}/PrivacyGuardDb.cpp
${server_src_dir}/main.cpp
${server_src_dir}/SocketService.cpp
-# ${server_src_dir}/CynaraService.cpp
+ ${server_src_dir}/CynaraService.cpp
${server_src_dir}/PrivacyGuardDaemon.cpp
${server_src_dir}/service/PrivacyInfoService.cpp
${server_src_dir}/NotificationServer.cpp
* limitations under the License.
*/
-#ifndef _CYNARASERVICE_H_
-#define _CYNARASERVICE_H_
+#ifndef _CYNARA_SERVICE_H_
+#define _CYNARA_SERVICE_H_
#include <string>
#include <mutex>
private:
static void* getEntriesThread(void* );
- static void* flushThread(void* );
+// static void* flushThread(void* );
public:
CynaraService(void);
~CynaraService(void);
static int updateDb(cynara_monitor_entry** monitor_entries);
};
-#endif //_CYNARASERVICE_H_
+#endif //_CYNARA_SERVICE_H_
\ No newline at end of file
#include "privacy_guard_client_types.h"
class SocketService;
-#if 0
// [CYNARA]
class CynaraService;
-#endif
class EXTERN_API PrivacyGuardDaemon
{
private:
static PrivacyGuardDaemon* pInstance;
SocketService* pSocketService;
-#if 0
- // [CYNARA]
+ // [CYNARA]
CynaraService* pCynaraService;
-#endif
private:
PrivacyGuardDaemon(void);
* limitations under the License.
*/
-#ifndef _PRIVACYGUARDDB_H_
-#define _PRIVACYGUARDDB_H_
+#ifndef _PRIVACY_GUARD_DB_H_
+#define _PRIVACY_GUARD_DB_H_
#include <string>
#include <memory>
int PgAddPrivacyAccessLog(const int userId, std::list < std::pair < std::string, std::string > > logInfoList);
- int PgAddPrivacyAccessLogForCynara(const int userId, const std::string packageId, const std::string privilege, const timespec *timestamp);
+ int PgAddPrivacyAccessLogForCynara(const int userId, const std::string packageId, const std::string privilege, const time_t timestamp);
int PgAddPrivacyAccessLogTest(const int userId, const std::string packageId, const std::string privacyId);
};
-#endif // _PRIVACYGUARDDB_H_
+#endif // _PRIVACY_GUARD_DB_H_
\ No newline at end of file
+++ /dev/null
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-#PROJECT(privacy-guard-server)
-
-SET(CMAKE_INSTALL_PREFIX /usr)
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-SET(EXEC_PREFIX "\${prefix}")
-SET(LIBDIR ${LIB_INSTALL_DIR})
-SET(INCLUDEDIR ${INCLUDE_INSTALL_DIR})
-SET(VERSION 0.0)
-
-SET(VERSION_MAJOR 0)
-SET(VERSION "${VERSION_MAJOR}.0.1")
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-
-INCLUDE(FindPkgConfig)
-#pkg_check_modules(pkgs REQUIRED dlog pkgmgr-info cynara-monitor)
-pkg_check_modules(pkgs REQUIRED dlog pkgmgr-info)
-
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(CMAKE_C_FLAGS_PROFILING " -g -pg")
-SET(CMAKE_CXX_FLAGS_PROFILING " -std=c++0x -g -pg")
-SET(CMAKE_C_FLAGS_DEBUG " -g")
-SET(CMAKE_CXX_FLAGS_DEBUG " -std=c++0x -g")
-SET(CMAKE_C_FLAGS_RELEASE " -g")
-SET(CMAKE_CXX_FLAGS_RELEASE " -std=c++0x -g")
-SET(CMAKE_C_FLAGS_CCOV " -g --coverage")
-SET(CMAKE_CXX_FLAGS_CCOV " -std=c++0x -g --coverage")
-
-SET(src_dir "./")
-SET(include_dir "./../inc/")
-SET(common_src_dir "./../../common/src/")
-SET(common_include_dir "./../../common/inc/")
-
-## Additional flag
-ADD_DEFINITIONS("-fvisibility=hidden")
-ADD_DEFINITIONS("-Wall -Werror")
-ADD_DEFINITIONS("-DDLOG_ERROR_ENABLED")
-
-###################################################################################################
-## for libprivacy-guard-server.so (library)
-INCLUDE_DIRECTORIES(${pkgs_INCLUDE_DIRS})
-SET(PRIVACY_GUARD_SERVER_SOURCES
- ${src_dir}/main.cpp
- ${src_dir}/SocketService.cpp
-# ${src_dir}/CynaraService.cpp
- ${src_dir}/PrivacyGuardDaemon.cpp
- ${common_src_dir}/SocketConnection.cpp
- ${common_src_dir}/SocketStream.cpp
- )
-SET(PRIVACY_GUARD_SERVER_HEADERS
- ${include_dir}/SocketService.h
-# ${include_dir}/CynaraService.h
- ${include_dir}/PrivacyGuardDaemon.h
- ${common_include_dir}/SocketConnection.h
-)
-SET(PRIVACY_GUARD_SERVER_LDFLAGS " -module -avoid-version ")
-SET(PRIVACY_GUARD_SERVER_CFLAGS " ${CFLAGS} -fPIC -I${include_dir}" -I${common_include_dir})
-#SET(PRIVACY_GUARD_SERVER_LIBADD " ")
-
-ADD_EXECUTABLE(privacy-guard-server ${PRIVACY_GUARD_SERVER_SOURCES})
-TARGET_LINK_LIBRARIES(privacy-guard-server ${pkgs_LDFLAGS} ${pkgs_LIBRARIES})
-SET_TARGET_PROPERTIES(privacy-guard-server PROPERTIES COMPILE_FLAGS "${PRIVACY_GUARD_SERVER_CFLAGS}")
-SET_TARGET_PROPERTIES(privacy-guard-server PROPERTIES SOVERSION ${VERSION_MAJOR})
-SET_TARGET_PROPERTIES(privacy-guard-server PROPERTIES VERSION ${VERSION})
-###################################################################################################
-
-CONFIGURE_FILE(../../privacy-guard-server.pc.in privacy-guard-server.pc @ONLY)
-
-INSTALL(TARGETS privacy-guard-server DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
-INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/privacy-guard-server.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(FILES ${PRIVACY_GUARD_SERVER_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR})
: m_signalToClose(-1)
, m_cynaraThread(-1)
{
-
}
CynaraService::~CynaraService(void)
{
-
}
int
CynaraService::initialize(void)
{
- PG_LOGI("CynaraService initializing");
+ PG_LOGD("[cynara_service] CynaraService initializing");
int res = cynara_monitor_configuration_create(&p_conf);
if(res != CYNARA_API_SUCCESS){
- PG_LOGE("cynara_monitor_configuration_create FAIL");
+ PG_LOGE("cynara_monitor_configuration_create() is failed.");
return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
-// cynara_monitor_configuration_set_buffer_size(p_conf, buffer_size);
-// res = cynara_monitor_initialize(&p_cynara_monitor, p_conf);
- res = cynara_monitor_initialize(&p_cynara_monitor, nullptr);
+
+ res = cynara_monitor_configuration_set_buffer_size(p_conf, CYNARA_BUFFER_SIZE);
+ if(res != CYNARA_API_SUCCESS){
+ PG_LOGE("cynara_monitor_configuration_set_buffer_size() is failed.");
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
+ }
+
+ res = cynara_monitor_initialize(&p_cynara_monitor, p_conf);
if(res != CYNARA_API_SUCCESS){
- PG_LOGE("cynara_monitor_initialize FAIL");
+ PG_LOGE("cynara_monitor_initialize() is failed.");
return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
int
CynaraService::start(void)
{
- PG_LOGI("CynaraService starting");
+ PG_LOGI("[cynara_service] CynaraService starting");
int res = 0;
char buf[256];
CynaraService::getEntriesThread(void* pData)
{
pthread_detach(pthread_self());
- PG_LOGI("Running get entries thread");
+ PG_LOGD("[cynara_service] Running get entries thread");
- pthread_t testThread;
- int result = pthread_create(&testThread, NULL, &flushThread, NULL);
- if(result){
- PG_LOGE("pthread_create FAIL");
+// pthread_t testThread;
+// int result = pthread_create(&testThread, NULL, &flushThread, NULL);
+// if(result){
+// PG_LOGE("pthread_create FAIL");
+// return (void*) PRIV_GUARD_ERROR_SYSTEM_ERROR;
+// }
+
+ // cynara_monitor_entries_get
+ // returned when the cynara buffer is full or cynara_monitor_entries_flush() is called from another thread
+ int res = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
+ if(res != CYNARA_API_SUCCESS){
+ PG_LOGE("cynara_monitor_entries_get FAIL");
return (void*) PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
-// while(1)
-// {
- // cynara_monitor_entries_get
- int res = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
- if(res != CYNARA_API_SUCCESS){
- PG_LOGE("cynara_monitor_entries_get FAIL");
- return (void*) PRIV_GUARD_ERROR_SYSTEM_ERROR;
- }
-
- res = CynaraService::updateDb(monitor_entries);
- if(res != PRIV_GUARD_ERROR_SUCCESS){
- PG_LOGE("updateDb FAIL");
- return (void*) res;
- }
-// }
+ res = CynaraService::updateDb(monitor_entries);
+ if(res != PRIV_GUARD_ERROR_SUCCESS){
+ PG_LOGE("updateDb FAIL");
+ return (void*) res;
+ }
- pthread_join(testThread, NULL);
+// pthread_join(testThread, NULL);
cynara_monitor_entries_free(monitor_entries);
return (void*) 0;
}
-void*
+/*void*
CynaraService::flushThread(void* pData)
{
pthread_detach(pthread_self());
- PG_LOGI("Running get flush thread");
+ PG_LOGD("Running get flush thread");
for(int i = 0; i < 1000000000;i++);
return (void*) PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
else{
- PG_LOGI("cynara_monitor_entries_flush SUCCESS");
+ PG_LOGD("cynara_monitor_entries_flush SUCCESS");
}
return (void*) 0;
-}
+}*/
int
-CynaraService::updateDb(cynara_monitor_entry** monitor_entries)
+CynaraService::updateDb(cynara_monitor_entry **monitor_entries)
{
+ PG_LOGD("[cynara_service]");
+
cynara_monitor_entry **entryIter = monitor_entries;
- PG_LOGI("entryIter = %x", entryIter);
+ PG_LOGD("entryIter = %x", entryIter);
-// DB update
- int userId = 0;
- std::string packageId;
- std::string privilege;
- const timespec *timestamp = { 0 };;
+ // DB update
+ const char *user = NULL, *client = NULL, *privilege = NULL;
+ const timespec *timestamp = NULL;
+ int userId;
+ std::string packageId, privilegeId;
+ time_t date;
while (*entryIter != nullptr) {
- packageId = cynara_monitor_entry_get_client(*entryIter);
- userId = (int)*cynara_monitor_entry_get_user(*entryIter);
+ user = cynara_monitor_entry_get_user(*entryIter);
+ TryReturn(user != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "User Id in the entry is NULL");
+ client = cynara_monitor_entry_get_client(*entryIter);
+ TryReturn(user != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "Package Id in the entry is NULL");
privilege = cynara_monitor_entry_get_privilege(*entryIter);
+ TryReturn(user != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "Privilege Id in the entry is NULL");
timestamp = cynara_monitor_entry_get_timestamp(*entryIter);
+ TryReturn(user != NULL, PRIV_GUARD_ERROR_SYSTEM_ERROR, , "timestamp in the entry is NULL");
- int ret = PrivacyGuardDb::getInstance()->PgAddPrivacyAccessLogForCynara(userId, packageId, privilege, timestamp);
+ userId = atoi(user);
+ packageId = client;
+ privilegeId = privilege;
+ date = timestamp->tv_sec;
+
+ // add access log
+ int ret = PrivacyGuardDb::getInstance()->PgAddPrivacyAccessLogForCynara(userId, packageId, privilegeId, date);
if(ret != PRIV_GUARD_ERROR_SUCCESS){
PG_LOGE("PgAddPrivacyAccessLogForCynara FAIL");
}
else{
- PG_LOGI("PgAddPrivacyAccessLogForCynara SUCCESS");
+ PG_LOGD("PgAddPrivacyAccessLogForCynara SUCCESS");
}
++entryIter;
int
CynaraService::stop(void)
{
- PG_LOGI("Stopping");
+ PG_LOGD("begin");
char buf[BUF_SIZE];
- int returned_value;
- if((returned_value = pthread_kill(m_cynaraThread, m_signalToClose)) < 0)
+ int ret;
+
+ if((ret = pthread_kill(m_cynaraThread, m_signalToClose)) < 0)
{
- errno = returned_value;
- PG_LOGE("pthread_kill() : %s", strerror_r(errno, buf, sizeof(buf)));
+ //errno = ret;
+ //PG_LOGE("pthread_kill() : %s", strerror_r(errno, buf, sizeof(buf)));
+ PG_LOGE("pthread_kill() : %s", strerror_r(ret, buf, sizeof(buf)));
return PRIV_GUARD_ERROR_IPC_ERROR;
}
pthread_join(m_cynaraThread, NULL);
- PG_LOGI("Stopped");
+ ret = cynara_monitor_finish(p_cynara_monitor);
+ if(ret != CYNARA_API_SUCCESS){
+ PG_LOGE("cynara_monitor_finish() is failed. [%d]", ret);
+ return PRIV_GUARD_ERROR_SYSTEM_ERROR;
+ }
+
+ PG_LOGD("end");
return PRIV_GUARD_ERROR_SUCCESS;
}
int
CynaraService::shutdown(void)
{
+ PG_LOGD("begin");
+
+ cynara_monitor_configuration_destroy(p_conf);
+
+ PG_LOGD("end");
+
return PRIV_GUARD_ERROR_SUCCESS;
}
#include "PrivacyGuardDaemon.h"
#include "PrivacyInfoService.h"
#include "SocketService.h"
-#if 0
// [CYNARA]
#include <CynaraService.h>
-#endif
PrivacyGuardDaemon* PrivacyGuardDaemon::pInstance = NULL;
PrivacyGuardDaemon*
PrivacyGuardDaemon::getInstance(void)
{
+ PG_LOGD("called");
+
if (pInstance == NULL)
pInstance = new PrivacyGuardDaemon();
return pInstance;
int
PrivacyGuardDaemon::initialize(void)
{
+ PG_LOGD("called");
+
if (pSocketService == NULL)
pSocketService = new SocketService();
-#if 0
+
+ PG_LOGD("calling pSocketService->initialize()");
+ pSocketService->initialize();
+
+ PG_LOGD("calling PrivacyInfoService::registerCallbacks(pSocketService)");
+ PrivacyInfoService::registerCallbacks(pSocketService);
+
// [CYNARA]
if (pCynaraService == NULL)
pCynaraService = new CynaraService();
-#endif
- pSocketService->initialize();
-#if 0
- // [CYNARA]
- pCynaraService->initialize();
-#endif
- PrivacyInfoService::registerCallbacks(pSocketService);
+ PG_LOGD("calling pCynaraService->initialize()");
+ pCynaraService->initialize();
return 0;
}
{
int res = 0;
+ PG_LOGD("calling pSocketService->start()");
if (pSocketService == NULL)
return PRIV_GUARD_ERROR_NOT_INITIALIZED;
res = pSocketService->start();
if(res != PRIV_GUARD_ERROR_SUCCESS){
PG_LOGE("FAIL");
}
-#if 0
+
// [CYNARA]
+/* PG_LOGD("calling pCynaraService->start()");
if (pCynaraService == NULL)
return PRIV_GUARD_ERROR_NOT_INITIALIZED;
res = pCynaraService->start();
if(res != PRIV_GUARD_ERROR_SUCCESS){
PG_LOGE("FAIL");
}
-#endif
+*/
return res;
}
int
PrivacyGuardDaemon::stop(void)
{
+ PG_LOGD("calling pSocketService->stop()");
pSocketService->stop();
-#if 0
- // [CYNARA]
- pCynaraService->stop();
-#endif
+
+// PG_LOGD("calling pCynaraService->stop()");
+// pCynaraService->stop();
return 0;
}
int
PrivacyGuardDaemon::shutdown(void)
{
+ PG_LOGD("calling pSocketService->shutdown()");
pSocketService->shutdown();
+// PG_LOGD("calling pCynaraService->shutdown()");
+// pCynaraService->shutdown();
+
return 0;
}
#include <pkgmgr-info.h>
#include <time.h>
#include <privilege_info.h>
+#include <cynara-monitor.h>
#include "Utils.h"
#include "PrivacyGuardDb.h"
#include "PrivacyIdInfo.h"
+
#define PRIVACY_GUARD_DAYS 7
#define UNIX_TIME_ONE_DAY (24 * 60 * 60) // 86400 secs
-#if 0
-// [CYNARA]
-#include "CynaraService.h"
-
-//static cynara_monitor_configuration *p_conf;
-static cynara_monitor *p_cynara_monitor;
-static cynara_monitor_entry **monitor_entries;
-#endif
-
std::mutex PrivacyGuardDb::m_singletonMutex;
PrivacyGuardDb* PrivacyGuardDb::m_pInstance = NULL;
GList *PrivacyGuardDb::m_privacy_list = NULL;
+static cynara_monitor_configuration *p_conf;
+static cynara_monitor *p_cynara_monitor;
+
void
PrivacyGuardDb::initialize(void)
{
+ m_bInitialized = false;
+
+ // get privacy list
int res = privilege_info_get_privacy_list(&m_privacy_list);
if (res != PRVMGR_ERR_NONE) {
PG_LOGE("Failed to get privacy list from security-privilege-manager [%d].", res);
+ //return PRIV_GUARD_ERROR_SYSTEM_ERROR;
+ return;
+ }
+
+ // cynara initialize
+ res = cynara_monitor_configuration_create(&p_conf);
+ if(res != CYNARA_API_SUCCESS){
+ PG_LOGE("cynara_monitor_configuration_create() is failed.");
+ //return PRIV_GUARD_ERROR_SYSTEM_ERROR;
+ return;
+ }
+
+ res = cynara_monitor_initialize(&p_cynara_monitor, p_conf);
+ if(res != CYNARA_API_SUCCESS){
+ PG_LOGE("cynara_monitor_initialize() is failed.");
+ //return PRIV_GUARD_ERROR_SYSTEM_ERROR;
return;
}
}
int
-PrivacyGuardDb::PgAddPrivacyAccessLogForCynara(const int userId, const std::string packageId, const std::string privilege, const timespec* timestamp)
+PrivacyGuardDb::PgAddPrivacyAccessLogForCynara(const int userId, const std::string packageId, const std::string privilegeId, const time_t date)
{
- ////////////////////////////////////////////////
- // check userId, packageId, privilege here..
- ////////////////////////////////////////////////
- if(timestamp->tv_sec <= 0) {
- PG_LOGE("Invalid timestamp value: [%d]", timestamp->tv_sec);
+ if(userId < 0 || date <= 0) {
+ PG_LOGE("Invalid parameter: userId: [%d], date: [%d]", userId, date);
return PRIV_GUARD_ERROR_INVALID_PARAMETER;
}
- int res = SQLITE_OK;
+ int res = -1;
+ std::string privacyId;
// change from privilege to privacy
- std::string privacyId;
- res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilege, privacyId);
+ res = PrivacyIdInfo::getPrivacyIdFromPrivilege(privilegeId, privacyId);
if (res == PRIV_GUARD_ERROR_NO_DATA) {
+ PG_LOGD("Input privilege[%s] is not related to any privacy. So skip it.", privilegeId.c_str());
return PRIV_GUARD_ERROR_SUCCESS;
}
- TryReturn( res == PRIV_GUARD_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege : %d", res);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "getPrivacyIdFromPrivilege is failed: [%d]", res);
- // change from timespec to time_t
- time_t logging_date;
- logging_date = timestamp->tv_sec;
+ // check monitor policy using userId, packageId, privacyId
+ int monitorPolicy;
+ res = PgGetMonitorPolicy(userId, packageId, privacyId, monitorPolicy);
+ TryReturn(res == PRIV_GUARD_ERROR_SUCCESS, res, , "PgGetMonitorPolicy is failed: [%d]", res);
+ if (monitorPolicy == 0) {
+ PG_LOGD("Monitor Policy is 0. So skip it. UserId:[%d], PrivacyId:[%s], PackageId:[%s], Policy:[%d]", userId, privacyId.c_str(), packageId.c_str(), monitorPolicy);
+ return PRIV_GUARD_ERROR_SUCCESS;
+ }
static const std::string QUERY_INSERT = std::string("INSERT INTO StatisticsMonitorInfo(USER_ID, PKG_ID, PRIVACY_ID, USE_DATE) VALUES(?, ?, ?, ?)");
}
TryCatchResLogReturn(m_bDBOpen == true, m_dbMutex.unlock(), PRIV_GUARD_ERROR_IO_ERROR, "openSqliteDB : %d", res);
- PG_LOGD("addlogToDb m_sqlHandler : %p", m_sqlHandler);
-
// prepare
res = sqlite3_prepare_v2(m_sqlHandler, QUERY_INSERT.c_str(), -1, &m_stmt, NULL);
TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_prepare_v2 : %d", res);
res = sqlite3_bind_text(m_stmt, 3, privacyId.c_str(), -1, SQLITE_TRANSIENT);
TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_text : %d", res);
- res = sqlite3_bind_int(m_stmt, 4, logging_date);
+ res = sqlite3_bind_int(m_stmt, 4, date);
TryCatchResLogReturn(res == SQLITE_OK, m_dbMutex.unlock(), PRIV_GUARD_ERROR_DB_ERROR, "sqlite3_bind_int : %d", res);
res = sqlite3_step(m_stmt);
{
int res = -1;
-#if 0
// [CYNARA] Fluch Entries
int ret= cynara_monitor_entries_flush(p_cynara_monitor);
if(ret != CYNARA_API_SUCCESS){
return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
- // [CYNARA] Get Entries
+/* // [CYNARA] Get Entries
ret = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
if(ret != CYNARA_API_SUCCESS){
PG_LOGE("cynara_monitor_entries_get FAIL");
PG_LOGE("updateDb FAIL");
return ret;
}
-#endif
-
+*/
static const std::string PKGID_SELECT = std::string("SELECT DISTINCT PKG_ID FROM StatisticsMonitorInfo WHERE USER_ID=? AND USE_DATE>=? AND USE_DATE<=?");
static const std::string PKGINFO_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PKG_ID=? AND USE_DATE>=? AND USE_DATE<=?");
sqlite3_stmt* infoStmt;
{
int res = -1;
-#if 0
// [CYNARA] Fluch Entries
int ret= cynara_monitor_entries_flush(p_cynara_monitor);
if(ret != CYNARA_API_SUCCESS){
return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
- // [CYNARA] Get Entries
+/* // [CYNARA] Get Entries
ret = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
if(ret != CYNARA_API_SUCCESS){
PG_LOGE("cynara_monitor_entries_get FAIL");
PG_LOGE("updateDb FAIL");
return ret;
}
-#endif
-
+*/
static const std::string PRIVACY_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?");
m_dbMutex.lock();
{
int res = -1;
-#if 0
// [CYNARA] Fluch Entries
int ret= cynara_monitor_entries_flush(p_cynara_monitor);
if(ret != CYNARA_API_SUCCESS){
return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
- // [CYNARA] Get Entries
+/* // [CYNARA] Get Entries
ret = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
if(ret != CYNARA_API_SUCCESS){
PG_LOGE("cynara_monitor_entries_get FAIL");
PG_LOGE("updateDb FAIL");
return ret;
}
-#endif
+*/
static const std::string PKGID_SELECT = std::string("SELECT DISTINCT PKG_ID FROM StatisticsMonitorInfo WHERE USER_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?");
static const std::string PKGINFO_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?");
{
int res = -1;
-#if 0
// [CYNARA] Fluch Entries
int ret= cynara_monitor_entries_flush(p_cynara_monitor);
if(ret != CYNARA_API_SUCCESS){
return PRIV_GUARD_ERROR_SYSTEM_ERROR;
}
- // [CYNARA] Get Entries
+/* // [CYNARA] Get Entries
ret = cynara_monitor_entries_get(p_cynara_monitor, &monitor_entries);
if(ret != CYNARA_API_SUCCESS){
PG_LOGE("cynara_monitor_entries_get FAIL");
PG_LOGE("updateDb FAIL");
return ret;
}
-#endif
+*/
static const std::string PRIVACY_SELECT = std::string("SELECT COUNT(*) FROM StatisticsMonitorInfo WHERE USER_ID=? AND PKG_ID=? AND PRIVACY_ID=? AND USE_DATE>=? AND USE_DATE<=?");
}
sqlite3_reset(infoStmt);
}
-
m_dbMutex.unlock();
return PRIV_GUARD_ERROR_SUCCESS;
if (m_bInitialized == true) {
m_dbMutex.lock();
g_list_free(m_privacy_list);
+ cynara_monitor_configuration_destroy(p_conf);
m_bInitialized = false;
m_dbMutex.unlock();
}
, m_signalToClose(-1)
, m_mainThread(-1)
{
-
+ PG_LOGD("SocketService() called.");
}
SocketService::~SocketService(void)
{
-
+ PG_LOGD("~SocketService() called.");
}
int
SocketService::initialize(void)
{
- PG_LOGI("SocketService initializing");
+ PG_LOGD("SocketService initializing");
char buf[BUF_SIZE];
m_listenFd = socket(AF_UNIX, SOCK_STREAM, 0);
void*
SocketService::serverThread(void* pData)
{
+ PG_LOGD("serverThread() called.");
pthread_detach(pthread_self());
SocketService &t = *static_cast< SocketService* > (pData);
- PG_LOGI("Running main thread");
+
+ PG_LOGD("Running main thread");
int ret = t.mainloop();
- if (ret < 0)
- {
+ if (ret < 0) {
return (void*) 1;
}
+
return (void*) 0;
}
int
SocketService::mainloop(void)
{
+ PG_LOGD("mainloop() called.");
+
char buf[BUF_SIZE];
+
if( listen(m_listenFd, MAX_LISTEN) == -1 ){
PG_LOGE("listen : %s", strerror_r(errno, buf, sizeof(buf)));
return PRIV_GUARD_ERROR_IPC_ERROR;
void*
SocketService::connectionThread(void* pData)
{
+ PG_LOGD("connectionThread() called.");
pthread_detach(pthread_self());
std::unique_ptr<ConnectionInfo> connectionInfo (static_cast<ConnectionInfo *>(pData));
SocketService &t = *static_cast<SocketService *>(connectionInfo->pData);
int
SocketService::connectionService(int fd)
{
+ PG_LOGD("connectionService() called.");
SocketConnection connector = SocketConnection(fd);
std::string interfaceName, methodName;
int
SocketService::stop(void)
{
- PG_LOGI("Stopping");
+ PG_LOGD("Stopping");
+
char buf[BUF_SIZE];
+
if(close(m_listenFd) == -1)
if(errno != ENOTCONN)
{
}
pthread_join(m_mainThread, NULL);
- PG_LOGI("Stopped");
+ PG_LOGD("Stopped");
+
return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::shutdown(void)
{
+ PG_LOGD("called");
return PRIV_GUARD_ERROR_SUCCESS;
}
int
SocketService::registerServiceCallback(const std::string &interfaceName, const std::string &methodName, socketServiceCallback callbackMethod)
{
+ PG_LOGD("called");
+
if(NULL == callbackMethod)
{
PG_LOGE("Null callback");
void
SocketService::addClientSocket(int clientSocket)
{
+ PG_LOGD("called");
+
std::lock_guard<std::mutex> guard(m_clientSocketListMutex);
m_clientSocketList.push_back(clientSocket);
}
void
SocketService::removeClientSocket(int clientSocket)
{
+ PG_LOGD("called");
+
std::lock_guard<std::mutex> guard(m_clientSocketListMutex);
m_clientSocketList.remove(clientSocket);
}
bool
SocketService::popClientSocket(int * pClientSocket)
{
+ PG_LOGD("called");
+
std::lock_guard<std::mutex> guard(m_clientSocketListMutex);
if(m_clientSocketList.empty())
return false;
void
SocketService::closeConnections(void)
{
+ PG_LOGD("called");
+
int clientSocket;
char buf[BUF_SIZE];
PG_LOGI("Closing client sockets");
}
}
- PG_LOGI("Connections closed");
+ PG_LOGD("Connections closed");
}
#include <glib.h>
#include "PrivacyGuardDaemon.h"
+// [kylee76]temp
+#include "Utils.h"
+
int
main(int argc, char* argv[])
{
+ PG_LOGD("called");
PrivacyGuardDaemon* pDaemon = PrivacyGuardDaemon::getInstance();
+ PG_LOGD("pDaemon->initialize()");
pDaemon->initialize();
+ PG_LOGD("pDaemon->start()");
pDaemon->start();
GMainLoop* pLoop;
pLoop = g_main_new(TRUE);
+ PG_LOGD("g_main_loop_run(pLoop)");
g_main_loop_run(pLoop);
+ PG_LOGD("pDaemon->stop()");
pDaemon->stop();
+ PG_LOGD("pDaemon->shutdown()");
pDaemon->shutdown();
return 0;