ADD_DEFINITIONS("-DNFC_MANAGER_MODULEDIR=\"${LIB_INSTALL_DIR}/nfc\"")
-#ADD_DEFINITIONS("-DSECURITY_SERVER")
ADD_DEFINITIONS("-DUSE_FULL_URI")
#ADD_DEFINITIONS("-DESE_ALWAYS_ON")
SET(WIN_PKG "${WIN_PKG} ecore-wayland")
ENDIF(WAYLAND_SUPPORT)
INCLUDE(FindPkgConfig)
-pkg_check_modules(client_pkgs REQUIRED security-server dlog vconf libtzplatform-config neardal
+pkg_check_modules(client_pkgs REQUIRED dlog vconf libtzplatform-config neardal
libssl appsvc svi capi-media-wav-player ${WIN_PKG})
IF(WAYLAND_SUPPORT)
#include <glib.h>
-#ifdef SECURITY_SERVER
-#include "security-server.h"
-#endif
-
#include "net_nfc_typedef.h"
#include "net_nfc_util_gdbus_internal.h"
#include "net_nfc_client_se.h"
#include "net_nfc_client_system_handler.h"
#include "net_nfc_client_handover.h"
-#ifdef SECURITY_SERVER
-static uint8_t *cookie;
-static size_t cookie_len;
-
-static void _init_smack()
-{
- if (cookie == NULL) {
- cookie_len = security_server_get_cookie_size();
- if (cookie_len > 0) {
- cookie = g_new0(uint8_t, cookie_len);
- if (cookie != NULL) {
- if (security_server_request_cookie((char*)cookie, cookie_len) < 0) {
- g_free(cookie);
- cookie = NULL;
- }
- }
- }
- }
-}
-
-static void _deinit_smack()
-{
- if (cookie != NULL) {
- g_free(cookie);
- cookie = NULL;
- }
-}
-#endif
-
GVariant *net_nfc_client_gdbus_get_privilege()
{
-#ifdef SECURITY_SERVER
- return net_nfc_util_gdbus_buffer_to_variant(cookie, cookie_len);
-#else
return net_nfc_util_gdbus_buffer_to_variant(NULL, 0);
-#endif
}
void net_nfc_client_gdbus_init(void)
{
-#ifdef SECURITY_SERVER
- _init_smack();
-#endif
if (net_nfc_client_manager_init() != NET_NFC_OK)
return;
if (net_nfc_client_tag_init() != NET_NFC_OK)
net_nfc_client_tag_deinit();
net_nfc_client_phdc_deinit();
net_nfc_client_manager_deinit();
-#ifdef SECURITY_SERVER
- _deinit_smack();
-#endif
}
ENDIF(WAYLAND_SUPPORT)
INCLUDE(FindPkgConfig)
IF(ARM_TARGET)
- pkg_check_modules(daemon_pkgs REQUIRED aul glib-2.0 gio-unix-2.0 security-server
+ pkg_check_modules(daemon_pkgs REQUIRED aul glib-2.0 gio-unix-2.0
vconf dlog tapi appsvc libcurl libssl svi capi-media-wav-player
pkgmgr pkgmgr-info capi-network-wifi pmapi wifi-direct
libtzplatform-config neardal ${WIN_PKG})
ELSE(ARM_TARGET)
- pkg_check_modules(daemon_pkgs REQUIRED aul glib-2.0 gio-unix-2.0 security-server
+ pkg_check_modules(daemon_pkgs REQUIRED aul glib-2.0 gio-unix-2.0
vconf dlog tapi appsvc libcurl libssl svi capi-media-wav-player
pkgmgr pkgmgr-info capi-network-wifi pmapi libtzplatform-config neardal
${WIN_PKG})
#include <glib.h>
#include "vconf.h"
-#ifdef SECURITY_SERVER
-#include "security-server.h"
-#endif
#include "net_nfc_server.h"
#include "net_nfc_debug_internal.h"
bool net_nfc_server_gdbus_check_privilege(GDBusMethodInvocation *invocation,
GVariant *privilege, const char *object, const char *right)
{
-#ifdef SECURITY_SERVER
- int result;
- data_s priv = { NULL, 0 };
-
- RETV_IF(NULL == right, false);
- RETV_IF(NULL == object, false);
- RETV_IF(NULL == privilege, false);
-
- net_nfc_util_gdbus_variant_to_data_s(privilege, &priv);
-
- result = security_server_check_privilege_by_cookie((char *)priv.buffer, object, right);
-
- net_nfc_util_free_data(&priv);
-
- if (result < 0)
- {
- NFC_ERR("permission denied : \"%s\", \"%s\"", object, right);
- g_dbus_method_invocation_return_dbus_error(invocation,
- "org.tizen.NetNfcService.Privilege",
- "Permission denied");
-
- return false;
- }
-#endif
const char *id = g_dbus_method_invocation_get_sender(invocation);
net_nfc_server_gdbus_add_client_context(id, NET_NFC_CLIENT_ACTIVE_STATE);
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gobject-2.0)
-BuildRequires: pkgconfig(security-server)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(tapi)
ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
INCLUDE(FindPkgConfig)
-pkg_check_modules(clientlib_pkges REQUIRED security-server dbus-glib-1 dlog ecore vconf)
+pkg_check_modules(clientlib_pkges REQUIRED dbus-glib-1 dlog ecore vconf)
FOREACH(flag ${clientlib_pkges_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ADD_DEFINITIONS("-DLLCP_MODE")
ADD_DEFINITIONS("-DNFC_APP_SUPPORTED")
ADD_DEFINITIONS("-DSAVE_TARGET_INFO_IN_CC")
-#ADD_DEFINITIONS("-DSECURITY_SERVER")
#ADD_DEFINITIONS("-DG_MAIN_LOOP")
#ADD_DEFINITIONS("-DUSE_ECORE_MAIN_LOOP")
ADD_DEFINITIONS("-DUSE_GLIB_MAIN_LOOP")
int written_size = 0;
/* calc message length */
-#ifdef SECURITY_SERVER
- total_size += (sizeof(cookies_size) + cookies_size);
-#endif
total_size += msg->length;
total_size += net_nfc_util_get_va_list_length(list);
memcpy(send_buffer + written_size, &total_size, sizeof(total_size));
written_size += sizeof(total_size);
-#ifdef SECURITY_SERVER
- /* -- security server cookie */
- memcpy(send_buffer + written_size, &cookies_size, sizeof(cookies_size));
- written_size += sizeof(cookies_size);
-
- memcpy(send_buffer + written_size, cookies, cookies_size);
- written_size += cookies_size;
-#endif
-
/* -- request message struct */
memcpy(send_buffer + written_size, msg, msg->length);
written_size += msg->length;
#ADD_DEFINITIONS("-DSLP_DEBUG")
ADD_DEFINITIONS("-DNFC_DEBUG_USE_DLOG -D_GNU_SOURCE")
#ADD_DEFINITIONS("-DUSE_UNIX_DOMAIN")
-#ADD_DEFINITIONS("-DSECURITY_SERVER")
ADD_LIBRARY(${NFC_COMMON_LIB} SHARED ${COMMON_LIB_SRCS})
SET_TARGET_PROPERTIES(${NFC_COMMON_LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
SET(WIN_PKG "${WIN_PKG} ecore-wayland")
ENDIF(WAYLAND_SUPPORT)
INCLUDE(FindPkgConfig)
-pkg_check_modules(manager_pkges REQUIRED aul glib-2.0 gobject-2.0 security-server dbus-glib-1 vconf dlog tapi appsvc libcurl bluetooth-api heynoti smartcard-service smartcard-service-common libssl pmapi svi capi-media-wav-player pkgmgr pkgmgr-info ${WIN_PKG})
+pkg_check_modules(manager_pkges REQUIRED aul glib-2.0 gobject-2.0 dbus-glib-1 vconf dlog tapi appsvc libcurl bluetooth-api heynoti smartcard-service smartcard-service-common libssl pmapi svi capi-media-wav-player pkgmgr pkgmgr-info ${WIN_PKG})
IF(WAYLAND_SUPPORT)
ADD_DEFINITIONS("-DHAVE_WAYLAND")
ADD_DEFINITIONS("-DNFC_APP_SUPPORTED")
ADD_DEFINITIONS("-DBROADCAST_MESSAGE")
ADD_DEFINITIONS("-DSAVE_TARGET_INFO_IN_CC")
-#ADD_DEFINITIONS("-DSECURITY_SERVER")
#ADD_DEFINITIONS("-DG_MAIN_LOOP")
#ADD_DEFINITIONS("-DUSE_ECORE_MAIN_LOOP")
ADD_DEFINITIONS("-DUSE_GLIB_MAIN_LOOP")
#include <glib.h>
#include "vconf.h"
-#include "security-server.h"
#include "net_nfc_server_dispatcher_private.h"
#include "net_nfc_typedef_private.h"
// DEBUG_SERVER_MSG("net_nfc_controller get command = [%d]", req_msg->request_type);
-#if 1
- if (!_net_nfc_check_dispatcher_privilege(req_msg))
- {
-// _net_nfc_util_free_mem(req_msg);
-// continue;
- }
-#endif
-
switch (req_msg->request_type)
{
case NET_NFC_MESSAGE_SERVICE_CLEANER :
return (void *)NULL;
}
-
-/* return true to authentication success; false to fail to authenticate */
-bool _net_nfc_check_dispatcher_privilege(net_nfc_request_msg_t *request_msg)
-{
- int client_fd_request = request_msg->client_fd;
- int ret_value;
-
- switch(request_msg->request_type)
- {
-#if 0
- case NET_NFC_MESSAGE_SERVICE_ACTIVATE:
- DEBUG_SERVER_MSG("checking NET_NFC_MESSAGE_SERVICE_ACTIVATE...");
- ret_value = security_server_check_privilege_by_sockfd(client_fd_request,"nfc-manager::admin","w");
- if (ret_value == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- DEBUG_SERVER_MSG("checking failed, and then send response to client");
-
- if (net_nfc_server_check_client_is_running(client_fd_request)){
- net_nfc_response_test_t resp = { 0, };
- resp.length = sizeof(net_nfc_response_test_t);
- resp.flags = request_msg->flags;
- resp.result = NET_NFC_SECURITY_FAIL;
- resp.trans_param = (void *)request_msg->user_param;
- net_nfc_send_response_msg(request_msg->client_fd, request_msg->request_type,(void *)&resp, sizeof(net_nfc_response_test_t), NULL);
-
- }
- return false;
- }
- DEBUG_SERVER_MSG("checking success");
- break;
-
-#endif
- case NET_NFC_MESSAGE_TRANSCEIVE:
- DEBUG_SERVER_MSG("checking NET_NFC_MESSAGE_TRANSCEIVE...");
- ret_value = security_server_check_privilege_by_sockfd(client_fd_request,"nfc-manager::tag","w");
-
- if (ret_value == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- DEBUG_SERVER_MSG("checking failed, and then send response to client");
-#if 0
-
- if (net_nfc_server_check_client_is_running(client_fd_request))
- {
- net_nfc_request_transceive_t *detail = (net_nfc_request_transceive_t *)request_msg;
- net_nfc_response_transceive_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_transceive_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
- resp.result = NET_NFC_SECURITY_FAIL;
-
- net_nfc_send_response_msg(request_msg->client_fd, request_msg->request_type, (void *)&resp, sizeof(net_nfc_response_transceive_t), NULL);
-
- }
- return false;
-#endif
- }
- DEBUG_SERVER_MSG("checking success");
- break;
-
- case NET_NFC_MESSAGE_READ_NDEF:
-
- DEBUG_SERVER_MSG("checking NET_NFC_MESSAGE_READ_NDEF...");
- ret_value = security_server_check_privilege_by_sockfd(client_fd_request,"nfc-manager::tag","w");
-
- if (ret_value == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- DEBUG_SERVER_MSG("checking failed, and then send response to client");
-#if 0
-
- if (net_nfc_server_check_client_is_running(client_fd_request))
- {
- net_nfc_request_read_ndef_t *detail = (net_nfc_request_read_ndef_t *)request_msg;
- net_nfc_response_write_ndef_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_read_ndef_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
- resp.result = NET_NFC_SECURITY_FAIL;
-
- net_nfc_send_response_msg(request_msg->client_fd, request_msg->request_type, (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
-
- }
- return false;
-#endif
- }
- DEBUG_SERVER_MSG("checking success");
- break;
-
- case NET_NFC_MESSAGE_WRITE_NDEF:
- DEBUG_SERVER_MSG("checking NET_NFC_MESSAGE_WRITE_NDEF...");
- ret_value = security_server_check_privilege_by_sockfd(client_fd_request,"nfc-manager::tag","w");
-
- if (ret_value == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- DEBUG_SERVER_MSG("checking failed, and then send response to client");
-#if 0
-
- if (net_nfc_server_check_client_is_running(client_fd_request))
- {
- net_nfc_request_write_ndef_t *detail = (net_nfc_request_write_ndef_t *)request_msg;
- net_nfc_response_write_ndef_t resp = { 0, };
-
- resp.length = sizeof(net_nfc_response_write_ndef_t);
- resp.flags = detail->flags;
- resp.trans_param = detail->trans_param;
- resp.result = NET_NFC_SECURITY_FAIL;
-
- net_nfc_send_response_msg(request_msg->client_fd, request_msg->request_type, (void *)&resp, sizeof(net_nfc_response_write_ndef_t), NULL);
-
- }
- return false;
-#endif
- }
- DEBUG_SERVER_MSG("checking success");
- break;
-
- case NET_NFC_MESSAGE_P2P_SEND:
- DEBUG_SERVER_MSG("checking NET_NFC_MESSAGE_P2P_SEND...");
- ret_value = security_server_check_privilege_by_sockfd(client_fd_request,"nfc-manager::p2p","w");
-
- if (ret_value == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- DEBUG_SERVER_MSG("checking failed, and then send response to client");
-#if 0
-
- if (net_nfc_server_check_client_is_running(client_fd_request))
- {
- net_nfc_request_p2p_send_t *exchanger = (net_nfc_request_p2p_send_t *)request_msg;
-
- net_nfc_response_p2p_send_t resp_msg = { 0, };
-
- resp_msg.length = sizeof(resp_msg);
- resp_msg.response_type = NET_NFC_MESSAGE_P2P_SEND;
- resp_msg.handle = exchanger->handle;
- resp_msg.result = NET_NFC_SECURITY_FAIL;
- resp_msg.trans_param = (void *)exchanger->user_param;
-
- net_nfc_send_response_msg(request_msg->client_fd,NET_NFC_MESSAGE_P2P_SEND, &resp_msg,sizeof(resp_msg), NULL);
-
- }
- return false;
-#endif
- }
- DEBUG_SERVER_MSG("checking success");
- break;
-
-#if 0
- case NET_NFC_MESSAGE_SNEP_START_SERVER :
- DEBUG_SERVER_MSG("checking NET_NFC_MESSAGE_SNEP_START_SERVER...");
- ret_value = security_server_check_privilege_by_sockfd(client_fd_request,"nfc-manager::p2p","rw");
-
- if (ret_value == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- DEBUG_SERVER_MSG("checking failed, and then send response to client");
- if (net_nfc_server_check_client_is_running(client_fd_request))
- {
- net_nfc_request_listen_socket_t *msg = (net_nfc_request_listen_socket_t *)request_msg;
- net_nfc_response_receive_socket_t resp = { 0 };
- resp.length = sizeof(resp);
- resp.response_type = NET_NFC_MESSAGE_SNEP_START_SERVER;
- resp.user_param = msg->user_param;
- resp.result = NET_NFC_SECURITY_FAIL;
- net_nfc_send_response_msg(request_msg->client_fd, request_msg->request_type, (void *)&resp, sizeof(net_nfc_response_receive_socket_t), NULL);
- }
- return false;
- }
- DEBUG_SERVER_MSG("checking success");
- break;
-
-#endif
-#if 0
- case NET_NFC_MESSAGE_SNEP_START_CLIENT :
- DEBUG_SERVER_MSG("checking NET_NFC_MESSAGE_SNEP_START_CLIENT...");
-
- ret_value = security_server_check_privilege_by_sockfd(client_fd_request,"nfc-manager::p2p","rw");
- if (ret_value == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- DEBUG_SERVER_MSG("checking failed, and then send response to client");
- if (net_nfc_server_check_client_is_running(client_fd_request))
- {
- net_nfc_request_snep_client_t *msg =(net_nfc_request_snep_client_t *)request_msg;
- net_nfc_response_receive_socket_t resp_msg = { 0, };
- resp_msg.length = sizeof(resp_msg);
- resp_msg.response_type = NET_NFC_MESSAGE_SNEP_START_CLIENT;
- resp_msg.user_param = msg->user_param;
- resp_msg.result = NET_NFC_SECURITY_FAIL;
- net_nfc_send_response_msg(request_msg->client_fd, request_msg->request_type, (void *)&resp_msg, sizeof(net_nfc_response_receive_socket_t), NULL);
- }
- return false;
- }
- DEBUG_SERVER_MSG("checking success");
- break;
-
-#endif
-#if 0
- case NET_NFC_MESSAGE_SNEP_STOP_SERVICE :
- ret_value = security_server_check_privilege_by_sockfd(client_fd_request,"nfc-manager::p2p","rw");
- if (ret_value == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- return false;
-
- }
- break;
-
-#endif
- default :
- return true;
- }
-
- return true;
-}
#include <errno.h>
#include "vconf.h"
-#include "security-server.h"
#include "net_nfc_typedef_private.h"
#include "net_nfc_debug_private.h"
/////////////////////////////
/* static variable */
-#ifdef SECURITY_SERVER
-static char *cookies = NULL;
-static int cookies_size = 0;
-static gid_t gid = 0;
-#endif
static pthread_mutex_t g_server_socket_lock = PTHREAD_MUTEX_INITIALIZER;
static net_nfc_server_info_t g_server_info = { 0, };
goto ERROR;
}
-#ifdef SECURITY_SERVER
- gid = security_server_get_gid(NET_NFC_MANAGER_OBJECT);
- if (gid == 0)
- {
- DEBUG_ERR_MSG("get gid from security server is failed. this object is not allowed by security server");
- goto ERROR;
- }
-
- if ((cookies_size = security_server_get_cookie_size()) > 0)
- {
- _net_nfc_util_alloc_mem(cookies, cookies_size);
- if (cookies == NULL)
- {
- DEBUG_ERR_MSG("alloc failed");
- goto ERROR;
- }
- }
- else
- {
- DEBUG_ERR_MSG("security_server_get_cookie_size failed");
- goto ERROR;
- }
-#endif
-
net_nfc_dispatcher_start_thread();
DEBUG_SERVER_MSG("server ipc is initialized");
return true;
ERROR :
-#ifdef SECURITY_SERVER
- if (cookies == NULL)
- {
- _net_nfc_util_free_mem(cookies);
- }
-#endif
-
if (g_server_info.server_src_id > 0)
{
g_source_remove(g_server_info.server_src_id);
/* cleanup client */
net_nfc_server_deinit_client_context();
-#ifdef SECURITY_SERVER
- if (cookies == NULL)
- {
- _net_nfc_util_free_mem(cookies);
- }
-#endif
-
if (g_server_info.server_src_id > 0)
{
g_source_remove(g_server_info.server_src_id);
return false;
}
-#ifdef SECURITY_SERVER
- uint32_t cookie_len = *(uint32_t *)(buffer + offset);
- offset += sizeof(cookie_len);
-
- if (cookie_len == cookies_size && (length - offset) > cookies_size)
- {
- int error = 0;
-
- /* copy cookie */
- memcpy(cookies, buffer + offset, cookies_size);
- offset += cookies_size;
-
- /* for debug */
-#if 0
- DEBUG_SERVER_MSG("recevied cookies");
- DEBUG_MSG_PRINT_BUFFER(cookies, cookie_len);
-#endif
-
- /* check cookie */
- if ((error = security_server_check_privilege(cookies, gid)) < 0)
- {
- DEBUG_ERR_MSG("failed to authentificate client [%d]", error);
- _net_nfc_util_free_mem(buffer);
- *result = NET_NFC_SECURITY_FAIL;
- return false;
- }
- }
- else
- {
- DEBUG_ERR_MSG("there is no cookie or invalid in message");
- _net_nfc_util_free_mem(buffer);
- *result = NET_NFC_SECURITY_FAIL;
- return false;
- }
-#endif
-
if (length > offset)
{
_net_nfc_util_alloc_mem(req_msg, length - offset);
case NET_NFC_MESSAGE_SERVICE_SET_LAUNCH_STATE :
{
DEBUG_SERVER_MSG("checking NET_NFC_MESSAGE_SERVICE_SET_LAUNCH_STATE...");
-#if 1
- int ret = security_server_check_privilege_by_sockfd(req_msg->client_fd,"nfc-manager::common","w");
-
- if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED)
- {
- DEBUG_SERVER_MSG("checking faile and return...");
-// return false;
- }
-#endif
net_nfc_request_set_launch_state_t *detail = (net_nfc_request_set_launch_state_t *)req_msg;