[PATCH v2 06/13] Enable support for passthru

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jeremy White <jwhite@xxxxxxxxxxxxxxx>

Enable support for passthru (e.g. direct to pcsc) smart cards in the
emul_options entry point in libcacard.

Signed-off-by: Jeremy White <jwhite@xxxxxxxxxxxxxxx>
Reviewed-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>
---
 src/vcard_emul_nss.c  | 28 +++++++++++++++++++++++++++-
 src/vcard_emul_type.c |  4 +++-
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/vcard_emul_nss.c b/src/vcard_emul_nss.c
index d046ea9..08a60c6 100644
--- a/src/vcard_emul_nss.c
+++ b/src/vcard_emul_nss.c
@@ -35,6 +35,9 @@
 #include "vevent.h"
 
 #include "vcardt_internal.h"
+#if defined(ENABLE_PCSC)
+#include "capcsc.h"
+#endif
 
 
 typedef enum {
@@ -896,6 +899,23 @@ vcard_emul_init(const VCardEmulOptions *options)
         options = &default_options;
     }
 
+#if defined(ENABLE_PCSC)
+    if (options->use_hw && options->hw_card_type == VCARD_EMUL_PASSTHRU) {
+        if (options->vreader_count > 0) {
+            fprintf(stderr, "Error: you cannot use a soft card and "
+                            "a passthru card simultaneously.\n");
+            return VCARD_EMUL_FAIL;
+        }
+
+        if (capcsc_init()) {
+            fprintf(stderr, "Error initializing PCSC interface.\n");
+            return VCARD_EMUL_FAIL;
+        }
+
+        return VCARD_EMUL_OK;
+    }
+#endif
+
     /* first initialize NSS */
     if (options->nss_db) {
         rv = NSS_Init(options->nss_db);
@@ -1299,5 +1319,11 @@ vcard_emul_usage(void)
 "hw_type, and parameters of hw_param.\n"
 "\n"
 "If more one or more soft= parameters are specified, these readers will be\n"
-"presented to the guest\n");
+"presented to the guest\n"
+#if defined(ENABLE_PCSC)
+"\n"
+"If a hw_type of PASSTHRU is given, a connection will be made to the hardware\n"
+"using libpcscslite.  Note that in that case, no soft cards are permitted.\n"
+#endif
+);
 }
diff --git a/src/vcard_emul_type.c b/src/vcard_emul_type.c
index 0c2fbb7..44cc305 100644
--- a/src/vcard_emul_type.c
+++ b/src/vcard_emul_type.c
@@ -7,6 +7,8 @@
  * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
  * See the COPYING file in the top-level directory.
  */
+#include "config.h"
+
 #include <strings.h>
 #include "vcardt.h"
 #include "vcard_emul_type.h"
@@ -44,7 +46,7 @@ VCardEmulType vcard_emul_type_from_string(const char *type_string)
      if (strcasecmp(type_string, "CAC") == 0) {
         return VCARD_EMUL_CAC;
      }
-#ifdef USE_PASSTHRU
+#ifdef ENABLE_PCSC
      if (strcasecmp(type_string, "PASSTHRU") == 0) {
         return VCARD_EMUL_PASSTHRU;
      }
-- 
2.4.3

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]