* limitations under the License.
*/
+/* standard library header */
#include <unistd.h>
#include <glib.h>
#include <gio/gio.h>
#include <string>
#include <sys/socket.h>
-#ifdef USER_SPACE_SMACK
-#include "security-server.h"
-#endif
-
+/* local header */
#include "smartcard-types.h"
#include "Debug.h"
#include "ByteArray.h"
#include "GDBusHelper.h"
#include "ServerGDBus.h"
+#ifdef USE_CYNARA
+#include "cynara-client.h"
+#include "cynara-creds-gdbus.h"
+#include "cynara-session.h"
+
+#define SMARTCARD_PRIVILEGE "http://tizen.org/privilege/secureelement"
+#endif
+
using namespace std;
+#ifdef __PRIVATE
+extern "C" bool smartcard_service_init_access_control(void *connection);
+extern "C" void smartcard_service_deinit_access_control();
+#endif
+
namespace smartcard_service_api
{
GDBusDispatcher::GDBusDispatcher() : Synchronous()
syncLock();
q.push(make_pair(cb, params));
- _INFO("request pushed, count [%d]", q.size());
+ _INFO("request pushed, count [%zu]", q.size());
if (q.size() == 1) {
/* start dispatch */
dispatcher->syncLock();
dispatcher->q.pop();
+ /* LCOV_EXCL_START */
if (dispatcher->q.size() > 0) {
- _INFO("remaining messages : %d", dispatcher->q.size());
+ _INFO("remaining messages : %zu", dispatcher->q.size());
result = true;
+ /* LCOV_EXCL_STOP */
} else {
_INFO("dispatch finished");
}
const gchar *name, const gchar *old_owner,
const gchar *new_owner, void *user_data)
{
+ /* LCOV_EXCL_START */
if (name == NULL || old_owner == NULL || new_owner == NULL) {
_ERR("invalid parameter");
return;
}
-
+ /* LCOV_EXCL_STOP */
if (strlen(new_owner) == 0) {
ClientInstance *client;
name_owner_changed((GDBusProxy *)connection,
name, old_owner, new_owner, user_data);
+
+ g_free(name);
+ g_free(old_owner);
+ g_free(new_owner);
}
bool ServerGDBus::_init()
&error);
if (dbus_proxy == NULL)
{
+ /* LCOV_EXCL_START */
_ERR("Can not create proxy : %s", error->message);
g_error_free(error);
return false;
+ /* LCOV_EXCL_STOP */
}
/* subscribe signal */
connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
if (connection != NULL) {
+ /* LCOV_EXCL_START */
} else {
_ERR("Can not get connection %s", error->message);
g_error_free(error);
return false;
}
+ /* LCOV_EXCL_STOP */
_init();
initReader();
initSession();
initChannel();
-
+#ifdef __PRIVATE
+ smartcard_service_init_access_control(connection);
+#endif
return true;
}
void ServerGDBus::deinit()
{
+#ifdef __PRIVATE
+ smartcard_service_deinit_access_control();
+#endif
deinitChannel();
deinitSession();
deinitReader();
if (_call_get_connection_unix_process_id_sync(
(GDBusProxy *)dbus_proxy, name,
&pid, NULL, &error) == true) {
+ /* LCOV_EXCL_START */
} else {
_ERR("_g_freedesktop_dbus_call_get_connection_unix_process_id_sync failed : %s", error->message);
g_error_free(error);
}
+ /* LCOV_EXCL_STOP */
return pid;
}
- static bool _is_authorized_request(GDBusMethodInvocation *invocation,
- const char *rights)
+#ifdef USE_CYNARA
+ static bool _get_credentials(GDBusMethodInvocation *invocation)
{
- bool result = true;
-#ifdef USER_SPACE_SMACK
- pid_t pid;
- const char *name;
- ClientInstance *instance;
+ int ret = 0;
+ int pid = 0;
+ char *user;
+ char *client;
+ char *client_session;
+ cynara *p_cynara = NULL;
+ const char *sender_unique_name;
+ GDBusConnection *connection;
+
+ connection = g_dbus_method_invocation_get_connection(invocation);
+ sender_unique_name = g_dbus_method_invocation_get_sender(invocation);
+
+ pid = ServerGDBus::getInstance().getPID(sender_unique_name);
+
+ ret = cynara_initialize(&p_cynara, NULL);
+ /* LCOV_EXCL_START */
+ if (ret != CYNARA_API_SUCCESS) {
+ _ERR("cynara_initialize() failed");
+ return false;
+ }
+ /* LCOV_EXCL_STOP */
- name = g_dbus_method_invocation_get_sender(invocation);
+ ret = cynara_creds_gdbus_get_user(connection, sender_unique_name, USER_METHOD_DEFAULT, &user);
+ /* LCOV_EXCL_START */
+ if (ret != CYNARA_API_SUCCESS) {
+ _ERR("cynara_creds_gdbus_get_user() failed");
+ return false;
+ }
+ /* LCOV_EXCL_STOP */
- instance = ServerResource::getInstance().getClient(name);
- if (instance != NULL) {
- pid = instance->getPID();
- } else {
- pid = ServerGDBus::getInstance().getPID(name);
+ ret = cynara_creds_gdbus_get_client(connection, sender_unique_name, CLIENT_METHOD_DEFAULT, &client);
+ /* LCOV_EXCL_START */
+ if (ret != CYNARA_API_SUCCESS) {
+ _ERR("cynara_creds_gdbus_get_client() failed");
+ g_free(user);
+ return false;
}
+ /* LCOV_EXCL_STOP */
+
+ _ERR("user :%s , client :%s ,unique_name : %s, pid() : %d", user, client, sender_unique_name, pid);
+
+ client_session = cynara_session_from_pid(pid);
- result = (security_server_check_privilege_by_pid(
- pid,
- "smartcard-service",
- rights) == SECURITY_SERVER_API_SUCCESS);
+ /* LCOV_EXCL_START */
+ if (!client_session) {
+ _ERR("cynara_session_from_pid() failed");
+ g_free(client);
+ g_free(user);
+ return false;
+ }
+ /* LCOV_EXCL_STOP */
+
+ ret = cynara_check(p_cynara, client, client_session, user, SMARTCARD_PRIVILEGE);
+ if ( ret == CYNARA_API_ACCESS_ALLOWED ) {
+ _INFO("cynara PASS");
+ }
+
+ g_free(client_session);
+ g_free(client);
+ g_free(user);
+
+ if (p_cynara) {
+ cynara_finish(p_cynara);
+ p_cynara = NULL;
+ }
+
+ return (ret == CYNARA_API_ACCESS_ALLOWED ) ? true : false;
+ }
#endif
+
+ static bool _is_authorized_request(GDBusMethodInvocation *invocation)
+ {
+ bool result = false;
+
+#ifdef USE_CYNARA
+ result = _get_credentials(invocation);
+#endif
+
+ _ERR("api security check result : %d", result);
+
return result;
}
/* generate certification hashes */
instance->generateCertificationHashes();
} else {
- _ERR("createClient failed");
+ _ERR("createClient failed"); /* LCOV_EXCL_LINE */
}
}
/* create service */
service = resource.createService(name);
if (service != NULL) {
-
handle = service->getHandle();
resource.getReaders(list);
if (list.size() == 0) {
_INFO("no secure elements");
}
+ /* LCOV_EXCL_START */
} else {
_ERR("createService failed");
result = SCARD_ERROR_IPC_FAILED;
}
+ /* LCOV_EXCL_STOP */
readers = _reader_to_variant(list);
GDBusMethodInvocation *invocation;
void *user_data;
+ /* LCOV_EXCL_START */
if (params.size() != 3) {
_ERR("invalid parameter");
return;
}
+ /* LCOV_EXCL_STOP */
object = (SmartcardServiceSeService *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
vector<void *> params;
/* apply user space smack */
- if (_is_authorized_request(invocation, "r") == true) {
+ if (_is_authorized_request(invocation) == true) {
g_object_ref(object);
params.push_back((void *)object);
params.push_back((void *)user_data);
GDBusDispatcher::push(_process_se_service, params);
+ /* LCOV_EXCL_START */
} else {
vector<pair<unsigned int, string> > list;
IntegerHandle::INVALID_HANDLE,
_reader_to_variant(list));
}
+ /* LCOV_EXCL_STOP */
return true;
}
static gboolean __process_shutdown(SmartcardServiceSeService *object,
GDBusMethodInvocation *invocation,
- intptr_t handle, void *user_data)
+ guint handle, void *user_data)
{
const char *name;
{
SmartcardServiceSeService *object;
GDBusMethodInvocation *invocation;
- intptr_t handle;
+ guint handle;
void *user_data;
+ /* LCOV_EXCL_START */
if (params.size() != 4) {
_ERR("invalid parameter");
return;
}
+ /* LCOV_EXCL_STOP */
object = (SmartcardServiceSeService *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- handle = (intptr_t)params[2];
+ handle = (gulong)params[2];
user_data = params[3];
__process_shutdown(object, invocation, handle, user_data);
static gboolean _handle_shutdown(SmartcardServiceSeService *object,
GDBusMethodInvocation *invocation,
- intptr_t handle,
+ guint handle,
void *user_data)
{
vector<void *> params;
/* apply user space smack */
- if (_is_authorized_request(invocation, "r") == true) {
+ if (_is_authorized_request(invocation) == true) {
g_object_ref(object);
params.push_back((void *)object);
params.push_back(user_data);
GDBusDispatcher::push(_process_shutdown, params);
+ /* LCOV_EXCL_START */
} else {
_ERR("access denied");
smartcard_service_se_service_complete_shutdown(object,
invocation, SCARD_ERROR_SECURITY_NOT_ALLOWED);
}
+ /* LCOV_EXCL_STOP */
return true;
}
G_CALLBACK(_handle_shutdown),
this);
+ /* LCOV_EXCL_START */
if (g_dbus_interface_skeleton_export(
G_DBUS_INTERFACE_SKELETON(seService),
connection,
return false;
}
+ /* LCOV_EXCL_STOP */
return true;
}
void ServerGDBus::emitReaderInserted(unsigned int reader_id,
const char *reader_name)
{
+ /* LCOV_EXCL_START */
smartcard_service_se_service_emit_reader_inserted(
SMARTCARD_SERVICE_SE_SERVICE(seService),
reader_id, reader_name);
+ /* LCOV_EXCL_STOP */
}
void ServerGDBus::emitReaderRemoved(unsigned int reader_id,
const char *reader_name)
{
+ /* LCOV_EXCL_START */
smartcard_service_se_service_emit_reader_removed(
SMARTCARD_SERVICE_SE_SERVICE(seService),
reader_id, reader_name);
+ /* LCOV_EXCL_STOP */
+ }
+
+ void ServerGDBus::emitCardInserted(unsigned int reader_id,
+ const char *reader_name)
+ {
+ /* LCOV_EXCL_START */
+ smartcard_service_se_service_emit_card_inserted(
+ SMARTCARD_SERVICE_SE_SERVICE(seService),
+ reader_id, reader_name);
+ /* LCOV_EXCL_STOP */
+ }
+
+ void ServerGDBus::emitCardRemoved(unsigned int reader_id,
+ const char *reader_name)
+ {
+ /* LCOV_EXCL_START */
+ smartcard_service_se_service_emit_card_removed(
+ SMARTCARD_SERVICE_SE_SERVICE(seService),
+ reader_id, reader_name);
+ /* LCOV_EXCL_STOP */
}
/* Reader *
*
*/
static gboolean __process_open_session(SmartcardServiceReader *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t reader_id, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint reader_id, void *user_data)
{
unsigned int handle = IntegerHandle::INVALID_HANDLE;
int result;
if (handle != IntegerHandle::INVALID_HANDLE) {
result = SCARD_ERROR_OK;
} else {
+ /* LCOV_EXCL_START */
_ERR("createSession failed [%d]", handle);
result = SCARD_ERROR_OUT_OF_MEMORY;
_ERR("request invalid reader handle [%d]", reader_id);
result = SCARD_ERROR_ILLEGAL_PARAM;
+ /* LCOV_EXCL_STOP */
}
/* response to client */
{
SmartcardServiceReader *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t reader_id;
+ guint service_id;
+ guint reader_id;
void *user_data;
if (params.size() != 5) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceReader *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- reader_id = (intptr_t)params[3];
+ service_id = (gulong)params[2];
+ reader_id = (gulong)params[3];
user_data = params[4];
__process_open_session(object, invocation, service_id,
static gboolean _handle_open_session(SmartcardServiceReader *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t reader_id, void *user_data)
+ guint service_id,
+ guint reader_id, void *user_data)
{
vector<void *> params;
/* apply user space smack */
- if (_is_authorized_request(invocation, "r") == true) {
+ if (_is_authorized_request(invocation) == true) {
g_object_ref(object);
params.push_back((void *)object);
GDBusDispatcher::push(_process_open_session, params);
} else {
+ /* LCOV_EXCL_START */
_ERR("access denied");
/* response to client */
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED,
IntegerHandle::INVALID_HANDLE);
+ /* LCOV_EXCL_STOP */
}
return true;
"/org/tizen/SmartcardService/Reader",
&error) == false)
{
+ /* LCOV_EXCL_START */
_ERR("Can not skeleton_export %s", error->message);
g_error_free(error);
reader = NULL;
return false;
+ /* LCOV_EXCL_STOP */
}
return true;
void ServerGDBus::deinitReader()
{
+ /* LCOV_EXCL_START */
if (reader != NULL) {
g_object_unref(reader);
reader = NULL;
}
+ /* LCOV_EXCL_STOP */
}
/* Session *
*
*/
static gboolean __process_close_session(SmartcardServiceSession *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t session_id, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint session_id, void *user_data)
{
const char *name;
resource.removeSession(name, service_id,
session_id);
} else {
- _ERR("invalid parameters");
+ _ERR("invalid parameters"); //LCOV_EXCL_LINE
}
/* response to client */
{
SmartcardServiceSession *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t session_id;
+ guint service_id;
+ guint session_id;
void *user_data;
if (params.size() != 5) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceSession *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- session_id = (intptr_t)params[3];
+ service_id = (gulong)params[2];
+ session_id = (gulong)params[3];
user_data = params[4];
__process_close_session(object, invocation, service_id,
static gboolean _handle_close_session(SmartcardServiceSession *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t session_id, void *user_data)
+ guint service_id,
+ guint session_id, void *user_data)
{
vector<void *> params;
/* apply user space smack */
- if (_is_authorized_request(invocation, "r") == true) {
+ if (_is_authorized_request(invocation) == true) {
g_object_ref(object);
params.push_back((void *)object);
GDBusDispatcher::push(_process_close_session, params);
} else {
+ /* LCOV_EXCL_START */
_ERR("access denied");
/* response to client */
smartcard_service_session_complete_close_session(object,
invocation, SCARD_ERROR_SECURITY_NOT_ALLOWED);
+ /* LCOV_EXCL_STOP */
}
return true;
}
static gboolean __process_get_atr(SmartcardServiceSession *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t session_id, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint session_id, void *user_data)
{
int result;
ByteArray resp;
name = g_dbus_method_invocation_get_sender(invocation);
client = resource.getService(name, service_id);
+ /* LCOV_EXCL_START */
if (client != NULL) {
Terminal *terminal;
terminal = client->getTerminal(session_id);
if (terminal != NULL) {
- int rv;
-
if (terminal->open() == true) {
- rv = terminal->getATRSync(resp);
- if (rv < SCARD_ERROR_OK) {
+ result = terminal->getATRSync(resp);
+ if (result < SCARD_ERROR_OK) {
_ERR("getATRSync failed : name [%s], service_id [%d], session_id [%d]", name, service_id, session_id);
-
- result = rv;
}
terminal->close();
result = SCARD_ERROR_UNAVAILABLE;
}
+ /* LCOV_EXCL_STOP */
atr = GDBusHelper::convertByteArrayToVariant(resp);
{
SmartcardServiceSession *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t session_id;
+ guint service_id;
+ guint session_id;
void *user_data;
if (params.size() != 5) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceSession *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- session_id = (intptr_t)params[3];
+ service_id = (gulong)params[2];
+ session_id = (gulong)params[3];
user_data = params[4];
__process_get_atr(object, invocation, service_id,
static gboolean _handle_get_atr(SmartcardServiceSession *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t session_id, void *user_data)
+ guint service_id,
+ guint session_id, void *user_data)
{
vector<void *> params;
/* apply user space smack */
- if (_is_authorized_request(invocation, "r") == true) {
+ if (_is_authorized_request(invocation) == true) {
g_object_ref(object);
params.push_back((void *)object);
GDBusDispatcher::push(_process_get_atr, params);
} else {
+ /* LCOV_EXCL_START */
ByteArray resp;
_ERR("access denied");
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED,
GDBusHelper::convertByteArrayToVariant(resp));
+ /* LCOV_EXCL_STOP */
}
return true;
}
static gboolean __process_open_channel(SmartcardServiceSession *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t session_id, intptr_t type, GVariant *aid, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint session_id, guint type, GVariant *aid, guint8 P2, void *user_data)
{
+ int channelNum = -1;
int result = SCARD_ERROR_UNKNOWN;
ByteArray resp;
GVariant *response = NULL;
const char *name;
_INFO("[MSG_REQUEST_OPEN_CHANNEL]");
+ _INFO("P2 is %x", P2);
ServerResource &resource = ServerResource::getInstance();
channelID = resource.createChannel(name,
service_id, session_id, type, tempAid);
+ /* LCOV_EXCL_START */
if (channelID != IntegerHandle::INVALID_HANDLE) {
ServerChannel *temp;
name, service_id, channelID);
if (temp != NULL) {
resp = temp->getSelectResponse();
-
+ channelNum = temp->getChannelNumber();
result = SCARD_ERROR_OK;
+ } else {
+ _ERR("getChannel is failed");
+ result = SCARD_ERROR_UNAVAILABLE;
}
} else {
_ERR("channel is null.");
/* set error value */
result = SCARD_ERROR_UNAVAILABLE;
}
+ /* LCOV_EXCL_STOP */
}
catch (ExceptionBase &e)
{
/* response to client */
smartcard_service_session_complete_open_channel(object,
- invocation, result, channelID, response);
+ invocation, result, channelID, channelNum, response);
return true;
}
{
SmartcardServiceSession *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t session_id;
- intptr_t type;
+ guint service_id;
+ guint session_id;
+ guint type;
+ guint8 P2;
GVariant *aid;
void *user_data;
- if (params.size() != 7) {
+ if (params.size() != 8) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceSession *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- session_id = (intptr_t)params[3];
- type = (intptr_t)params[4];
+ service_id = (gulong)params[2];
+ session_id = (gulong)params[3];
+ type = (gulong)params[4];
aid = (GVariant *)params[5];
- user_data = params[6];
+ P2 = (guint8)((gulong)params[6]);
+ user_data = params[7];
__process_open_channel(object, invocation, service_id,
- session_id, type, aid, user_data);
+ session_id, type, aid, P2, user_data);
g_object_unref(object);
g_object_unref(invocation);
- g_object_unref(aid);
+ g_variant_unref(aid);
}
static gboolean _handle_open_channel(SmartcardServiceSession *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t session_id, intptr_t type, GVariant *aid, void *user_data)
+ guint service_id,
+ guint session_id, guint type, GVariant *aid, guint8 P2, void *user_data)
{
vector<void *> params;
/* apply user space smack */
- if (_is_authorized_request(invocation, "rw") == true) {
+ if (_is_authorized_request(invocation) == true) {
g_object_ref(object);
params.push_back((void *)object);
params.push_back((void *)session_id);
params.push_back((void *)type);
- g_object_ref(aid);
+ g_variant_ref(aid);
params.push_back((void *)aid);
+ params.push_back((void *)((int)P2));
params.push_back(user_data);
GDBusDispatcher::push(_process_open_channel, params);
} else {
+ /* LCOV_EXCL_START */
ByteArray resp;
_ERR("access denied");
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED,
IntegerHandle::INVALID_HANDLE,
+ -1,
GDBusHelper::convertByteArrayToVariant(resp));
+ /* LCOV_EXCL_STOP */
}
return true;
"/org/tizen/SmartcardService/Session",
&error) == false)
{
+ /* LCOV_EXCL_START */
_ERR("Can not skeleton_export %s", error->message);
g_error_free(error);
session = NULL;
return false;
+ /* LCOV_EXCL_STOP */
}
return true;
*
*/
static gboolean __process_close_channel(SmartcardServiceChannel *object,
- GDBusMethodInvocation *invocation, intptr_t service_id,
- intptr_t channel_id, void *user_data)
+ GDBusMethodInvocation *invocation, guint service_id,
+ guint channel_id, void *user_data)
{
int result;
const char *name;
{
SmartcardServiceChannel *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t channel_id;
+ guint service_id;
+ guint channel_id;
void *user_data;
if (params.size() != 5) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceChannel *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- channel_id = (intptr_t)params[3];
+ service_id = (gulong)params[2];
+ channel_id = (gulong)params[3];
user_data = params[4];
__process_close_channel(object, invocation, service_id,
static gboolean _handle_close_channel(SmartcardServiceChannel *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id, intptr_t channel_id, void *user_data)
+ guint service_id, guint channel_id, void *user_data)
{
vector<void *> params;
/* apply user space smack */
- if (_is_authorized_request(invocation, "r") == true) {
+ if (_is_authorized_request(invocation) == true) {
g_object_ref(object);
params.push_back((void *)object);
GDBusDispatcher::push(_process_close_channel, params);
} else {
+ /* LCOV_EXCL_START */
_ERR("access denied");
/* response to client */
object,
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED);
+ /* LCOV_EXCL_STOP */
}
return true;
static gboolean __process_transmit(SmartcardServiceChannel *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t channel_id,
+ guint service_id,
+ guint channel_id,
GVariant *command,
void *user_data)
{
name = g_dbus_method_invocation_get_sender(invocation);
channel = resource.getChannel(name, service_id, channel_id);
+ /* LCOV_EXCL_START */
if (channel != NULL) {
int rv;
ByteArray cmd;
result = SCARD_ERROR_UNAVAILABLE;
}
+ /* LCOV_EXCL_STOP */
response = GDBusHelper::convertByteArrayToVariant(resp);
{
SmartcardServiceChannel *object;
GDBusMethodInvocation *invocation;
- intptr_t service_id;
- intptr_t channel_id;
+ guint service_id;
+ guint channel_id;
GVariant *command;
void *user_data;
if (params.size() != 6) {
+ /* LCOV_EXCL_START */
_ERR("invalid parameter");
return;
+ /* LCOV_EXCL_STOP */
}
object = (SmartcardServiceChannel *)params[0];
invocation = (GDBusMethodInvocation *)params[1];
- service_id = (intptr_t)params[2];
- channel_id = (intptr_t)params[3];
+ service_id = (gulong)params[2];
+ channel_id = (gulong)params[3];
command = (GVariant *)params[4];
user_data = params[5];
g_object_unref(command);
}
+ static GVariant *_copy_variant(GVariant *src)
+ {
+ GVariantBuilder builder;
+
+ GVariantIter *iter;
+ guint8 element;
+ guint i;
+
+ g_variant_get(src, "a(y)", &iter);
+
+ g_variant_builder_init(&builder, G_VARIANT_TYPE("a(y)"));
+
+ for (i = 0; g_variant_iter_loop(iter, "(y)", &element); i++) {
+ g_variant_builder_add(&builder, "(y)", element);
+ }
+
+ g_variant_iter_free(iter);
+
+ return g_variant_builder_end(&builder);
+ }
+
static gboolean _handle_transmit(SmartcardServiceChannel *object,
GDBusMethodInvocation *invocation,
- intptr_t service_id,
- intptr_t channel_id,
+ guint service_id,
+ guint channel_id,
GVariant *command,
void *user_data)
{
vector<void *> params;
+ GVariant *_command;
+
+ _command = _copy_variant(command);
/* apply user space smack */
- if (_is_authorized_request(invocation, "r") == true) {
+ if (_is_authorized_request(invocation) == true) {
/* enqueue message */
g_object_ref(object);
params.push_back((void *)object);
params.push_back((void *)service_id);
params.push_back((void *)channel_id);
- g_object_ref(command);
- params.push_back((void *)command);
+ g_object_ref(_command);
+ params.push_back((void *)_command);
params.push_back(user_data);
GDBusDispatcher::push(_process_transmit, params);
} else {
+ /* LCOV_EXCL_START */
ByteArray resp;
_ERR("access denied");
invocation,
SCARD_ERROR_SECURITY_NOT_ALLOWED,
GDBusHelper::convertByteArrayToVariant(resp));
+ /* LCOV_EXCL_STOP */
}
return true;
"/org/tizen/SmartcardService/Channel",
&error) == false)
{
+ /* LCOV_EXCL_START */
_ERR("Can not skeleton_export %s", error->message);
g_error_free(error);
channel = NULL;
return false;
+ /* LCOV_EXCL_STOP */
}
return true;