etrunko / rpms / spice-gtk

Forked from rpms/spice-gtk 4 years ago
Clone
Blob Blame History Raw
From 65df616e3030f555b864567f319dfef04ed423ea Mon Sep 17 00:00:00 2001
From: Christophe Fergeau <cfergeau@redhat.com>
Date: Thu, 11 Jul 2013 15:18:33 +0200
Subject: [PATCH 2/8] smartcard: Handle VCARD_EMUL_INIT_ALREADY_INITED

When initializing a software smartcard, vcard_emul_init() can
report success, error, or indicate that initialization has already
been done. In this last case, we would assume that an error occurred
instead of behaving as if the initialization succeeded.

vcard_emul_init() can end up being called multiple time if the
smartcard channel gets destroyed and recreated during the lifetime
of the application

Fixes rhbz#815639
---
 gtk/smartcard-manager.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gtk/smartcard-manager.c b/gtk/smartcard-manager.c
index 4b1efe2..2a0e397 100644
--- a/gtk/smartcard-manager.c
+++ b/gtk/smartcard-manager.c
@@ -408,6 +408,7 @@ static gboolean smartcard_manager_init(SpiceSession *session,
 {
     gchar *emul_args = NULL;
     VCardEmulOptions *options = NULL;
+    VCardEmulError emul_init_status;
     gchar *dbname = NULL;
     GStrv certificates = NULL;
     gboolean retval = FALSE;
@@ -448,7 +449,9 @@ static gboolean smartcard_manager_init(SpiceSession *session,
 
 init:
     SPICE_DEBUG("vcard_emul_init");
-    if (vcard_emul_init(options) != VCARD_EMUL_OK) {
+    emul_init_status = vcard_emul_init(options);
+    if ((emul_init_status != VCARD_EMUL_OK)
+            && (emul_init_status != VCARD_EMUL_INIT_ALREADY_INITED)) {
         *err = g_error_new(SPICE_CLIENT_ERROR,
                            SPICE_CLIENT_ERROR_FAILED,
                            "Failed to initialize smartcard");
-- 
1.8.3.1