[Spice-devel] [PATCH v2 06/13] Enable support for passthru
marcandre.lureau at redhat.com
marcandre.lureau at redhat.com
Fri Oct 9 09:15:59 PDT 2015
From: Jeremy White <jwhite at codeweavers.com>
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 at codeweavers.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
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
More information about the Spice-devel
mailing list