From 5efb8ef519114663fc16ad732b7d94f2b734f065 Mon Sep 17 00:00:00 2001 From: youngman Date: Tue, 22 Dec 2015 09:28:08 +0900 Subject: [PATCH] Check privileges for Tizen 3.0 Change-Id: I4077b01de9167eb05e464c106b6170751fb2d969 Signed-off-by: youngman --- common/ic-dbus.xml | 1 + daemon/CMakeLists.txt | 11 +- daemon/icd-cynara.c | 210 +++++++++++++++++++++++++++++++++++ daemon/icd-cynara.h | 27 +++++ daemon/icd-dbus.c | 178 ++++++++++++++++++++++++++++- daemon/icd-ioty.c | 10 +- daemon/icd.c | 9 ++ lib/icl-lite-resource.c | 2 +- lib/icl-resource.c | 2 +- lib/include/iotcon-client.h | 23 +++- lib/include/iotcon-internal.h | 8 +- lib/include/iotcon-lite-resource.h | 14 ++- lib/include/iotcon-remote-resource.h | 45 ++++++-- lib/include/iotcon-resource.h | 29 +++-- lib/include/iotcon-response.h | 5 +- packaging/iotcon.conf.in | 80 +------------ packaging/iotcon.spec | 5 + 17 files changed, 542 insertions(+), 117 deletions(-) create mode 100644 daemon/icd-cynara.c create mode 100644 daemon/icd-cynara.h diff --git a/common/ic-dbus.xml b/common/ic-dbus.xml index c3aaf28..8d37412 100644 --- a/common/ic-dbus.xml +++ b/common/ic-dbus.xml @@ -5,6 +5,7 @@ + diff --git a/daemon/CMakeLists.txt b/daemon/CMakeLists.txt index b576825..ae253cd 100644 --- a/daemon/CMakeLists.txt +++ b/daemon/CMakeLists.txt @@ -7,8 +7,15 @@ SET(DAEMON_SRCS ${DAEMON_SRCS} ${CMAKE_SOURCE_DIR}/common/ic-dbus.c) SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/common/ic-dbus.c PROPERTIES GENERATED TRUE) -pkg_check_modules(daemon_pkgs REQUIRED gio-2.0 dlog gio-unix-2.0 capi-system-info - capi-system-system-settings iotivity) +SET(PKG_MODULES gio-2.0 dlog gio-unix-2.0 capi-system-info capi-system-system-settings + iotivity) + +IF(NEW_SECURE) + SET(PKG_MODULES ${PKG_MODULES} cynara-client cynara-session cynara-creds-gdbus) + ADD_DEFINITIONS("-DIOTCON_CYNARA") +ENDIF(NEW_SECURE) + +pkg_check_modules(daemon_pkgs REQUIRED ${PKG_MODULES}) FOREACH(flag ${daemon_pkgs_CFLAGS_OTHER}) IF(${flag} MATCHES "\\-D+") diff --git a/daemon/icd-cynara.c b/daemon/icd-cynara.c new file mode 100644 index 0000000..64a2a94 --- /dev/null +++ b/daemon/icd-cynara.c @@ -0,0 +1,210 @@ +/* + * 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. + */ + +#include +#include +#include +#ifdef IOTCON_CYNARA +#include +#include +#include +#endif + +#include "iotcon.h" +#include "ic-common.h" +#include "icd.h" +#include "icd-cynara.h" + +static const char *_icd_privileges_network[] = { + /* network */ + "http://tizen.org/privilege/bluetooth", + "http://tizen.org/privilege/network.get", + "http://tizen.org/privilege/wifidirect", + NULL, +}; + +static const char *_icd_privileges_data[] = { + /* network */ + "http://tizen.org/privilege/bluetooth", + "http://tizen.org/privilege/network.get", + "http://tizen.org/privilege/wifidirect", + /* data */ + "http://tizen.org/privilege/d2d.datasharing", + NULL, +}; + +static const char *_icd_privileges_device[] = { + /* network */ + "http://tizen.org/privilege/bluetooth", + "http://tizen.org/privilege/network.get", + "http://tizen.org/privilege/wifidirect", + /* data */ + "http://tizen.org/privilege/d2d.datasharing", + /* device */ + "http://tizen.org/privilege/systemsettings", + NULL, +}; + +#ifdef IOTCON_CYNARA +static cynara *_cynara; +#endif + +int icd_cynara_init() +{ +#ifdef IOTCON_CYNARA + int ret; + ret = cynara_initialize(&_cynara, NULL); + + if (CYNARA_API_SUCCESS != ret) { + ERR("cynara_initialize() Fail(%d)", ret); + return IOTCON_ERROR_SYSTEM; + } +#endif + + return IOTCON_ERROR_NONE; +} + +void icd_cynara_deinit() +{ +#ifdef IOTCON_CYNARA + if (_cynara) + cynara_finish(_cynara); + + _cynara = NULL; +#endif +} + + +static int _icd_cynara_check(GDBusMethodInvocation *invocation, const char **privileges) +{ +#ifdef IOTCON_CYNARA + FN_CALL; + int i = 0; + int ret; + pid_t pid; + char *user = NULL; + char *client = NULL; + char *session = NULL; + const char *sender = NULL; + GDBusConnection *conn = NULL; + + RETV_IF(NULL == _cynara, IOTCON_ERROR_SYSTEM); + RETV_IF(NULL == invocation, IOTCON_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == privileges, IOTCON_ERROR_INVALID_PARAMETER); + + conn = g_dbus_method_invocation_get_connection(invocation); + if (NULL == conn) { + ERR("g_dbus_method_invocation_get_connection() return NULL"); + return IOTCON_ERROR_SYSTEM; + } + + sender = g_dbus_method_invocation_get_sender(invocation); + if (NULL == sender) { + ERR("g_dbus_method_invocation_get_sender() return NULL"); + return IOTCON_ERROR_SYSTEM; + } + + ret = cynara_creds_gdbus_get_client(conn, sender, CLIENT_METHOD_SMACK, &client); + if (CYNARA_API_SUCCESS != ret) { + ERR("cynara_creds_dbus_get_client() Fail(%d)", ret); + return IOTCON_ERROR_SYSTEM; + } + + ret = cynara_creds_gdbus_get_user(conn, sender, USER_METHOD_UID, &user); + if (CYNARA_API_SUCCESS != ret) { + ERR("cynara_creds_dbus_get_user() Fail(%d)", ret); + free(client); + return IOTCON_ERROR_SYSTEM; + } + + ret = cynara_creds_gdbus_get_pid(conn, sender, &pid); + if (CYNARA_API_SUCCESS != ret) { + ERR("cynara_creds_gdbus_get_pid() Fail(%d)", ret); + free(user); + free(client); + return IOTCON_ERROR_SYSTEM; + } + + session = cynara_session_from_pid(pid); + if (NULL == session) { + ERR("cynara_session_from_pid() return NULL"); + free(user); + free(client); + return IOTCON_ERROR_SYSTEM; + } + + while (privileges[i]) { + SECURE_DBG("privileges[%d]: %s, user: %s, client: %s", i, privileges[i], user, client); + ret = cynara_check(_cynara, client, session, user, privileges[i]); + if (CYNARA_API_ACCESS_DENIED == ret) { + ERR("Denied (%s)", privileges[i]); + free(session); + free(user); + free(client); + return IOTCON_ERROR_PERMISSION_DENIED; + } else if (CYNARA_API_ACCESS_ALLOWED != ret) { + ERR("cynara_check(%s) Fail(%d)", privileges[i], ret); + free(session); + free(user); + free(client); + return IOTCON_ERROR_SYSTEM; + } + i++; + } + free(session); + free(user); + free(client); +#endif + return IOTCON_ERROR_NONE; +} + + +int icd_cynara_check_network(GDBusMethodInvocation *invocation) +{ + int ret; + + ret = _icd_cynara_check(invocation, _icd_privileges_network); + if (IOTCON_ERROR_NONE != ret) + ERR("_icd_cynara_check() Fail(%d)", ret); + + return ret; +} + + +int icd_cynara_check_data(GDBusMethodInvocation *invocation) +{ + int ret; + + ret = _icd_cynara_check(invocation, _icd_privileges_data); + if (IOTCON_ERROR_NONE != ret) + ERR("_icd_cynara_check() Fail(%d)", ret); + + return ret; +} + + +int icd_cynara_check_device(GDBusMethodInvocation *invocation) +{ + int ret; + + ret = _icd_cynara_check(invocation, _icd_privileges_device); + if (IOTCON_ERROR_NONE != ret) + ERR("_icd_cynara_check() Fail(%d)", ret); + + return ret; +} + + diff --git a/daemon/icd-cynara.h b/daemon/icd-cynara.h new file mode 100644 index 0000000..69b7bbb --- /dev/null +++ b/daemon/icd-cynara.h @@ -0,0 +1,27 @@ +/* + * 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. + */ +#ifndef __IOT_CONNECTIVITY_MANAGER_DAEMON_CYNARA_H__ +#define __IOT_CONNECTIVITY_MANAGER_DAEMON_CYNARA_H__ + +#include + +int icd_cynara_init(); +void icd_cynara_deinit(); +int icd_cynara_check_network(GDBusMethodInvocation *invocation); +int icd_cynara_check_data(GDBusMethodInvocation *invocation); +int icd_cynara_check_device(GDBusMethodInvocation *invocation); + +#endif /*__IOT_CONNECTIVITY_MANAGER_DAEMON_CYNARA_H__*/ diff --git a/daemon/icd-dbus.c b/daemon/icd-dbus.c index c5e9e0f..e1f0ef3 100644 --- a/daemon/icd-dbus.c +++ b/daemon/icd-dbus.c @@ -25,6 +25,7 @@ #include "ic-dbus.h" #include "icd.h" #include "icd-ioty.h" +#include "icd-cynara.h" #include "icd-dbus.h" static icDbus *icd_dbus_object; @@ -530,7 +531,8 @@ static gboolean _dbus_handle_register_resource(icDbus *object, const gchar *uri_path, const gchar* const *resource_types, gint ifaces, - gint properties) + gint properties, + gboolean is_lite) { FN_CALL; int ret; @@ -538,6 +540,22 @@ static gboolean _dbus_handle_register_resource(icDbus *object, OCResourceHandle handle; int64_t signal_number = 0; + if (true == is_lite) { + ret = icd_cynara_check_data(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_data() Fail(%d)", ret); + ic_dbus_complete_register_resource(object, invocation, signal_number, ret); + return TRUE; + } + } else { + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_register_resource(object, invocation, signal_number, ret); + return TRUE; + } + } + handle = icd_ioty_register_resource(uri_path, resource_types, ifaces, properties); if (handle) { sender = g_dbus_method_invocation_get_sender(invocation); @@ -573,6 +591,13 @@ static gboolean _dbus_handle_unregister_resource(icDbus *object, sender = g_dbus_method_invocation_get_sender(invocation); _icd_dbus_resource_list_remove(sender, ICD_INT64_TO_POINTER(resource)); + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_unregister_resource(object, invocation); + return TRUE; + } + ret = icd_ioty_unregister_resource(ICD_INT64_TO_POINTER(resource)); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_unregister_resource() Fail(%d)", ret); @@ -588,6 +613,13 @@ static gboolean _dbus_handle_bind_interface(icDbus *object, { int ret; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_bind_interface(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_bind_interface(ICD_INT64_TO_POINTER(resource), iface); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_bind_interface() Fail(%d)", ret); @@ -603,6 +635,13 @@ static gboolean _dbus_handle_bind_type(icDbus *object, { int ret; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_bind_type(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_bind_type(ICD_INT64_TO_POINTER(resource), type); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_bind_type() Fail(%d)", ret); @@ -618,6 +657,13 @@ static gboolean _dbus_handle_bind_resource(icDbus *object, { int ret; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_bind_resource(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_bind_resource(ICD_INT64_TO_POINTER(parent), ICD_INT64_TO_POINTER(child)); if (IOTCON_ERROR_NONE != ret) @@ -634,6 +680,13 @@ static gboolean _dbus_handle_unbind_resource(icDbus *object, { int ret; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_unbind_resource(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_unbind_resource(ICD_INT64_TO_POINTER(parent), ICD_INT64_TO_POINTER(child)); if (IOTCON_ERROR_NONE != ret) @@ -657,9 +710,17 @@ static gboolean _dbus_handle_find_resource(icDbus *object, const gchar *sender; int64_t signal_number; + signal_number = icd_dbus_generate_signal_number(); + + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_find_resource(object, invocation, signal_number, ret); + return TRUE; + } + sender = g_dbus_method_invocation_get_sender(invocation); - signal_number = icd_dbus_generate_signal_number(); ret = icd_ioty_find_resource(host_address, connectivity, type, is_secure, timeout, signal_number, sender); if (IOTCON_ERROR_NONE != ret) @@ -679,10 +740,19 @@ static gboolean _dbus_handle_observer_start(icDbus *object, { int ret; const gchar *sender; - OCDoHandle observe_h; int64_t signal_number; + OCDoHandle observe_h = 0; signal_number = icd_dbus_generate_signal_number(); + + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_observer_start(object, invocation, signal_number, + ICD_POINTER_TO_INT64(observe_h)); + return TRUE; + } + sender = g_dbus_method_invocation_get_sender(invocation); observe_h = icd_ioty_observer_start(resource, observe_policy, query, @@ -718,6 +788,13 @@ static gboolean _dbus_handle_observer_stop(icDbus *object, int ret; const gchar *sender; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_observer_stop(object, invocation, ret); + return TRUE; + } + sender = g_dbus_method_invocation_get_sender(invocation); _icd_dbus_observe_list_remove(sender, ICD_INT64_TO_POINTER(observe_h)); @@ -739,6 +816,15 @@ static gboolean _dbus_handle_notify(icDbus *object, { int ret; + /* iotcon_resource_notify() + * iotcon_lite_resource_update_state() */ + ret = icd_cynara_check_data(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_data() Fail(%d)", ret); + ic_dbus_complete_notify(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_notify(ICD_INT64_TO_POINTER(resource), notify_msg, observers); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_notify() Fail(%d)", ret); @@ -754,6 +840,13 @@ static gboolean _dbus_handle_send_response(icDbus *object, { int ret; + ret = icd_cynara_check_data(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_data() Fail(%d)", ret); + ic_dbus_complete_send_response(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_send_response(response); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_send_response() Fail(%d)", ret); @@ -774,6 +867,14 @@ static gboolean _dbus_handle_get_device_info(icDbus *object, int64_t signal_number; signal_number = icd_dbus_generate_signal_number(); + + ret = icd_cynara_check_device(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_device() Fail(%d)", ret); + ic_dbus_complete_get_device_info(object, invocation, signal_number, ret); + return TRUE; + } + sender = g_dbus_method_invocation_get_sender(invocation); ret = icd_ioty_get_info(ICD_DEVICE_INFO, host_address, connectivity, timeout, @@ -797,6 +898,14 @@ static gboolean _dbus_handle_get_platform_info(icDbus *object, int64_t signal_number; signal_number = icd_dbus_generate_signal_number(); + + ret = icd_cynara_check_data(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_data() Fail(%d)", ret); + ic_dbus_complete_get_platform_info(object, invocation, signal_number, ret); + return TRUE; + } + sender = g_dbus_method_invocation_get_sender(invocation); ret = icd_ioty_get_info(ICD_PLATFORM_INFO, host_address, connectivity, timeout, @@ -816,6 +925,13 @@ static gboolean _dbus_handle_start_presence(icDbus *object, { int ret; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_start_presence(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_start_presence(time_to_live); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_start_presence() Fail(%d)", ret); @@ -831,6 +947,13 @@ static gboolean _dbus_handle_stop_presence(icDbus *object, { int ret; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_start_presence(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_stop_presence(); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_stop_presence() Fail(%d)", ret); @@ -849,7 +972,15 @@ static gboolean _dbus_handle_subscribe_presence(icDbus *object, { int ret; const gchar *sender; - OCDoHandle presence_h; + OCDoHandle presence_h = NULL; + + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_subscribe_presence(object, invocation, + ICD_POINTER_TO_INT64(presence_h)); + return TRUE; + } presence_h = icd_ioty_subscribe_presence(ICD_PRESENCE, host_address, connectivity, type, NULL); @@ -885,6 +1016,13 @@ static gboolean _dbus_handle_unsubscribe_presence(icDbus *object, int ret; const gchar *sender; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_unsubscribe_presence(object, invocation, ret); + return TRUE; + } + sender = g_dbus_method_invocation_get_sender(invocation); _icd_dbus_presence_list_remove(sender, ICD_INT64_TO_POINTER(presence_h)); @@ -930,7 +1068,14 @@ static gboolean _dbus_handle_start_monitoring(icDbus *object, gint connectivity) { int ret; - int64_t signal_number; + int64_t signal_number = 0; + + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_start_monitoring(object, invocation, signal_number, ret); + return TRUE; + } ret = icd_ioty_start_encap(ICD_ENCAP_MONITORING, uri_path, host_address, connectivity, &signal_number); @@ -950,6 +1095,13 @@ static gboolean _dbus_handle_stop_monitoring(icDbus *object, { int ret; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_stop_monitoring(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_stop_encap(ICD_ENCAP_MONITORING, uri_path, host_address); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_stop_encap() Fail(%d)", ret); @@ -967,7 +1119,14 @@ static gboolean _dbus_handle_start_caching(icDbus *object, gint connectivity) { int ret; - int64_t signal_number; + int64_t signal_number = 0; + + ret = icd_cynara_check_data(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_data() Fail(%d)", ret); + ic_dbus_complete_start_monitoring(object, invocation, signal_number, ret); + return TRUE; + } ret = icd_ioty_start_encap(ICD_ENCAP_CACHING, uri_path, host_address, connectivity, &signal_number); @@ -987,6 +1146,13 @@ static gboolean _dbus_handle_stop_caching(icDbus *object, { int ret; + ret = icd_cynara_check_network(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_network() Fail(%d)", ret); + ic_dbus_complete_stop_monitoring(object, invocation, ret); + return TRUE; + } + ret = icd_ioty_stop_encap(ICD_ENCAP_CACHING, uri_path, host_address); if (IOTCON_ERROR_NONE != ret) ERR("icd_ioty_stop_encap() Fail(%d)", ret); diff --git a/daemon/icd-ioty.c b/daemon/icd-ioty.c index 50c3128..3acda99 100644 --- a/daemon/icd-ioty.c +++ b/daemon/icd-ioty.c @@ -29,6 +29,7 @@ #include "ic-dbus.h" #include "ic-utils.h" #include "icd.h" +#include "icd-cynara.h" #include "icd-payload.h" #include "icd-dbus.h" #include "icd-ioty.h" @@ -609,6 +610,13 @@ static gboolean _icd_ioty_crud(int type, OCConnectivityType oic_conn_type; OCDevAddr dev_addr = {0}; + ret = icd_cynara_check_data(invocation); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_check_data() Fail(%d)", ret); + icd_ioty_complete_error(type, invocation, ret); + return TRUE; + } + switch (type) { case ICD_CRUD_GET: cbdata.cb = icd_ioty_ocprocess_get_cb; @@ -628,7 +636,7 @@ static gboolean _icd_ioty_crud(int type, break; default: ERR("Invalid CRUD Type(%d)", type); - return FALSE; + return TRUE; } g_variant_get(resource, "(&s&sba(qs)i)", &uri_path, &host, &is_secure, &options, diff --git a/daemon/icd.c b/daemon/icd.c index fcf7598..a888deb 100644 --- a/daemon/icd.c +++ b/daemon/icd.c @@ -18,6 +18,7 @@ #include "icd.h" #include "icd-dbus.h" #include "icd-ioty.h" +#include "icd-cynara.h" #include "icd-ioty-ocprocess.h" #define ICD_ALL_INTERFACES "0.0.0.0" @@ -60,8 +61,16 @@ int main(int argc, char **argv) return -1; } + ret = icd_cynara_init(); + if (IOTCON_ERROR_NONE != ret) { + ERR("icd_cynara_init() Fail(%d)", ret); + icd_ioty_deinit(thread); + icd_dbus_deinit(id); + } + g_main_loop_run(loop); + icd_cynara_deinit(); icd_ioty_deinit(thread); icd_dbus_deinit(id); g_main_loop_unref(loop); diff --git a/lib/icl-lite-resource.c b/lib/icl-lite-resource.c index 6ade69b..63ce405 100644 --- a/lib/icl-lite-resource.c +++ b/lib/icl-lite-resource.c @@ -305,7 +305,7 @@ API int iotcon_lite_resource_create(const char *uri_path, } ic_dbus_call_register_resource_sync(icl_dbus_get_object(), uri_path, types, iface, - properties, &signal_number, &(resource->handle), NULL, &error); + properties, true, &signal_number, &(resource->handle), NULL, &error); if (error) { ERR("ic_dbus_call_register_resource_sync() Fail(%s)", error->message); ret = icl_dbus_convert_dbus_error(error->code); diff --git a/lib/icl-resource.c b/lib/icl-resource.c index 18f98ef..86b3a46 100644 --- a/lib/icl-resource.c +++ b/lib/icl-resource.c @@ -188,7 +188,7 @@ API int iotcon_resource_create(const char *uri_path, } ic_dbus_call_register_resource_sync(icl_dbus_get_object(), uri_path, types, ifaces, - properties, &signal_number, &(resource->handle), NULL, &error); + properties, false, &signal_number, &(resource->handle), NULL, &error); if (error) { ERR("ic_dbus_call_register_resource_sync() Fail(%s)", error->message); ret = icl_dbus_convert_dbus_error(error->code); diff --git a/lib/include/iotcon-client.h b/lib/include/iotcon-client.h index bc01988..fb4c300 100644 --- a/lib/include/iotcon-client.h +++ b/lib/include/iotcon-client.h @@ -72,7 +72,9 @@ typedef void (*iotcon_presence_cb)(iotcon_presence_h presence, iotcon_error_e er * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @remarks The length of @a resource_type should be less than or equal to 61.\n * The @a resource_type must start with a lowercase alphabetic character, followed by a sequence @@ -115,7 +117,9 @@ int iotcon_add_presence_cb(const char *host_address, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @param[in] presence_handle The presence handle to be unsubscribed * @@ -326,7 +330,9 @@ typedef void (*iotcon_found_resource_cb)(iotcon_remote_resource_h resource, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @remarks The length of @a resource_type should be less than or equal to 61.\n * The @a resource_type must start with a lowercase alphabetic character, followed by a sequence @@ -387,7 +393,11 @@ typedef void (*iotcon_device_info_cb)(iotcon_device_info_h device_info, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/systemsettings + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] host_address The host address of remote server * @param[in] connectivity_type The connectivity type @@ -462,7 +472,10 @@ typedef void (*iotcon_platform_info_cb)(iotcon_platform_info_h platform_info, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] host_address The host address of remote server * @param[in] connectivity_type The connectivity type diff --git a/lib/include/iotcon-internal.h b/lib/include/iotcon-internal.h index f2af0d4..54542cf 100644 --- a/lib/include/iotcon-internal.h +++ b/lib/include/iotcon-internal.h @@ -31,7 +31,9 @@ extern "C" { * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @remarks If @a time_to_live is 0, server will set default value as 60 seconds.\n * If @a time_to_live is very big, server will set maximum value as (60 * 60 * 24) seconds. @@ -58,7 +60,9 @@ int iotcon_start_presence(unsigned int time_to_live); * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @return 0 on success, otherwise a negative error value. * @retval #IOTCON_ERROR_NONE Successful diff --git a/lib/include/iotcon-lite-resource.h b/lib/include/iotcon-lite-resource.h index 4bbe334..879ac4a 100644 --- a/lib/include/iotcon-lite-resource.h +++ b/lib/include/iotcon-lite-resource.h @@ -138,7 +138,10 @@ static void _update_brightness(int brightness) * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @remarks @a uri_path length must be less than or equal 36.\n * You must destroy @a resource_handle by calling iotcon_lite_resource_destroy() @@ -173,7 +176,9 @@ int iotcon_lite_resource_create(const char *uri_path, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @remarks When a normal variable is used, there are only dbus error and permission\n * denied error. If the errors of this API are not handled, then you must check\n @@ -195,6 +200,11 @@ int iotcon_lite_resource_destroy(iotcon_lite_resource_h resource); * @brief Updates state into the lite resource handle * * @since_tizen 3.0 + * @privlevel public + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] resource The handle of the lite resource * @param[in] state The state handle to update diff --git a/lib/include/iotcon-remote-resource.h b/lib/include/iotcon-remote-resource.h index 022f1fa..2a82c30 100644 --- a/lib/include/iotcon-remote-resource.h +++ b/lib/include/iotcon-remote-resource.h @@ -202,7 +202,9 @@ typedef void (*iotcon_remote_resource_observe_cb)(iotcon_remote_resource_h resou * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @param[in] resource The handle of the resource * @param[in] observe_policy The type to specify how client wants to observe. @@ -235,7 +237,9 @@ int iotcon_remote_resource_observe_register(iotcon_remote_resource_h resource, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @param[in] resource The handle of the resource * @@ -286,7 +290,10 @@ typedef void (*iotcon_remote_resource_response_cb)(iotcon_remote_resource_h reso * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] resource The handle of the resource * @param[in] query The query to send to server @@ -316,7 +323,10 @@ int iotcon_remote_resource_get(iotcon_remote_resource_h resource, iotcon_query_h * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] resource The handle of the resource * @param[in] repr The handle of the representation @@ -350,7 +360,10 @@ int iotcon_remote_resource_put(iotcon_remote_resource_h resource, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] resource The handle of the resource * @param[in] repr The handle of the representation @@ -384,7 +397,10 @@ int iotcon_remote_resource_post(iotcon_remote_resource_h resource, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] resource The handle of the resource * @param[in] cb The callback function @@ -433,7 +449,10 @@ typedef void (*iotcon_remote_resource_cached_representation_changed_cb)( * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] resource The handle of the remote resource to be cached * @param[in] cb The callback function to add into callback list @@ -460,7 +479,9 @@ int iotcon_remote_resource_start_caching(iotcon_remote_resource_h resource, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @param[in] resource The handle of the remote resource * @@ -502,7 +523,9 @@ typedef void (*iotcon_remote_resource_state_changed_cb)(iotcon_remote_resource_h * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @param[in] resource The handle of the remote resource * @param[in] cb The callback function to add into callback list @@ -526,7 +549,9 @@ int iotcon_remote_resource_start_monitoring(iotcon_remote_resource_h resource, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @param[in] resource The handle of the remote resource * diff --git a/lib/include/iotcon-resource.h b/lib/include/iotcon-resource.h index b8f25dc..8a3903e 100644 --- a/lib/include/iotcon-resource.h +++ b/lib/include/iotcon-resource.h @@ -161,7 +161,9 @@ typedef void (*iotcon_request_handler_cb)(iotcon_resource_h resource, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @remarks @a uri_path length must be less than or equal 36.\n * You must destroy @a resource by calling iotcon_resource_destroy() @@ -206,7 +208,9 @@ int iotcon_resource_create(const char *uri_path, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @remarks When a normal variable is used, there are only dbus error and permission\n * denied error. If the errors of this API are not handled, then you must check\n @@ -236,7 +240,9 @@ int iotcon_resource_destroy(iotcon_resource_h resource_handle); * @details The @a iface could be one of #iotcon_interface_e. * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @remarks Sets only one interface to @a iface. If not, @a iface will be ignored. * @@ -265,7 +271,9 @@ int iotcon_resource_bind_interface(iotcon_resource_h resource, iotcon_interface_ * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @remarks The length of @a resource_type should be less than or equal to 61.\n * The @a resource_type must start with a lowercase alphabetic character, followed by a sequence @@ -325,7 +333,9 @@ int iotcon_resource_set_request_handler(iotcon_resource_h resource, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @param[in] parent The handle of the parent resource * @param[in] child The handle of the child resource to be added to the parent resource @@ -354,7 +364,9 @@ int iotcon_resource_bind_child_resource(iotcon_resource_h parent, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect * * @param[in] parent The handle of the parent resource * @param[in] child The handle of the child resource to be unbound from the parent resource @@ -383,7 +395,10 @@ int iotcon_resource_unbind_child_resource(iotcon_resource_h parent, * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] resource The handle of the resource * @param[in] repr The handle of the representation diff --git a/lib/include/iotcon-response.h b/lib/include/iotcon-response.h index fb703e0..9526f05 100644 --- a/lib/include/iotcon-response.h +++ b/lib/include/iotcon-response.h @@ -334,7 +334,10 @@ int iotcon_response_set_options(iotcon_response_h resp, iotcon_options_h options * * @since_tizen 3.0 * @privlevel public - * @privilege %http://tizen.org/privilege/internet + * @privilege %http://tizen.org/privilege/bluetooth + * @privilege %http://tizen.org/privilege/network.get + * @privilege %http://tizen.org/privilege/wifidirect + * @privilege %http://tizen.org/privilege/d2d.datasharing * * @param[in] resp The handle of the response to send * diff --git a/packaging/iotcon.conf.in b/packaging/iotcon.conf.in index 555a478..30dd8bc 100644 --- a/packaging/iotcon.conf.in +++ b/packaging/iotcon.conf.in @@ -2,86 +2,8 @@ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packaging/iotcon.spec b/packaging/iotcon.spec index 2c34576..5159fc4 100644 --- a/packaging/iotcon.spec +++ b/packaging/iotcon.spec @@ -18,6 +18,11 @@ BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(capi-system-system-settings) BuildRequires: pkgconfig(iotivity) +%if 0%{?tizen_version_major} >= 3 +BuildRequires: pkgconfig(cynara-client) +BuildRequires: pkgconfig(cynara-session) +BuildRequires: pkgconfig(cynara-creds-gdbus) +%endif %if "%{tizen}" == "2.3" BuildRequires: python-xml %endif -- 2.7.4