summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packaging/smartcard-service.spec2
-rw-r--r--server/ServerGDBus.cpp15
-rw-r--r--server/ServerResource.cpp27
-rw-r--r--server/ServerSession.cpp12
4 files changed, 44 insertions, 12 deletions
diff --git a/packaging/smartcard-service.spec b/packaging/smartcard-service.spec
index bf21ac6..84e86b9 100644
--- a/packaging/smartcard-service.spec
+++ b/packaging/smartcard-service.spec
@@ -4,7 +4,7 @@
Name: smartcard-service
Summary: Smartcard Service
-Version: 0.1.29
+Version: 0.1.30
Release: 0
Group: Network & Connectivity/Service
License: Apache-2.0
diff --git a/server/ServerGDBus.cpp b/server/ServerGDBus.cpp
index 5f68c03..f0f1b08 100644
--- a/server/ServerGDBus.cpp
+++ b/server/ServerGDBus.cpp
@@ -856,12 +856,19 @@ namespace smartcard_service_api
if (terminal != NULL) {
int rv;
- if ((rv = terminal->getATRSync(resp)) == 0) {
- result = SCARD_ERROR_OK;
+ if (terminal->open() == true) {
+ rv = terminal->getATRSync(resp);
+ if (rv < SCARD_ERROR_OK) {
+ _ERR("getATRSync failed : name [%s], service_id [%d], session_id [%d]", name, service_id, session_id);
+
+ result = rv;
+ }
+
+ terminal->close();
} else {
- _ERR("getATRSync failed : name [%s], service_id [%d], session_id [%d]", name, service_id, session_id);
+ _ERR("terminal->open failed");
- result = rv;
+ result = SCARD_ERROR_UNAVAILABLE;
}
} else {
_ERR("getTerminal failed : name [%s], service_id [%d], session_id [%d]", name, service_id, session_id);
diff --git a/server/ServerResource.cpp b/server/ServerResource.cpp
index 790abdc..9b72607 100644
--- a/server/ServerResource.cpp
+++ b/server/ServerResource.cpp
@@ -336,10 +336,17 @@ namespace smartcard_service_api
session = service->getSession(sessionID);
if (terminal != NULL && session != NULL)
{
- result = _createChannel(terminal, service, channelType, sessionID, aid);
- if (result == IntegerHandle::INVALID_HANDLE)
- {
- _ERR("create channel failed [%d]", sessionID);
+ if (terminal->open() == true) {
+ result = _createChannel(terminal, service, channelType, sessionID, aid);
+ if (result == IntegerHandle::INVALID_HANDLE)
+ {
+ _ERR("create channel failed [%d]", sessionID);
+
+ terminal->close();
+ }
+ } else {
+ _ERR("terminal open failed");
+ throw ExceptionBase(SCARD_ERROR_UNAVAILABLE);
}
}
else
@@ -386,7 +393,19 @@ namespace smartcard_service_api
if ((instance = getService(name, handle)) != NULL)
{
+ ServerChannel *channel;
+ Terminal *terminal = NULL;
+
+ channel = instance->getChannel(channelID);
+ if (channel != NULL) {
+ terminal = channel->getTerminal();
+ }
+
instance->closeChannel(channelID);
+
+ if (terminal != NULL) {
+ terminal->close();
+ }
}
else
{
diff --git a/server/ServerSession.cpp b/server/ServerSession.cpp
index fcbc37a..0c73fe8 100644
--- a/server/ServerSession.cpp
+++ b/server/ServerSession.cpp
@@ -59,10 +59,16 @@ namespace smartcard_service_api
/* call get atr to terminal */
if (atr.isEmpty()) {
if (terminal != NULL) {
- int error = terminal->getATRSync(atr);
+ if (terminal->open() == true) {
+ int error = terminal->getATRSync(atr);
- if (error < SCARD_ERROR_OK) {
- _ERR("getATRSync failed, [%d]", error);
+ if (error < SCARD_ERROR_OK) {
+ _ERR("getATRSync failed, [%d]", error);
+ }
+
+ terminal->close();
+ } else {
+ _ERR("terminal->open failed");
}
} else {
_ERR("terminal is null.");