1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

scd: Let the CCID module auto detach the kernel driver.

* scd/ccid-driver.c (ccid_open_usb_reader): Call
libusb_set_auto_detach_kernel_driver.

* scd/scdaemon.c (oCompatibilityFlags): New.
(opts): Add option "compatibility-flags".
(compatibility_flags): New.
(main): Parse flags.
* scd/scdaemon.h (opt): Add field compat_flags.
(COMPAT_CCID_NO_AUTO_DETACH): New.
This commit is contained in:
Werner Koch 2024-03-06 11:54:33 +01:00
parent 00b877ecda
commit a1ea3b13e0
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
3 changed files with 41 additions and 0 deletions

View File

@ -1779,6 +1779,20 @@ ccid_open_usb_reader (const char *spec_reader_name,
#ifdef USE_NPTH #ifdef USE_NPTH
npth_unprotect (); npth_unprotect ();
#endif #endif
if (!(opt.compat_flags & COMPAT_CCID_NO_AUTO_DETACH))
{
rc = libusb_set_auto_detach_kernel_driver (idev, 1);
if (rc)
{
#ifdef USE_NPTH
npth_protect ();
#endif
DEBUGOUT_1 ("note: set_auto_detach_kernel_driver failed: %d\n", rc);
#ifdef USE_NPTH
npth_unprotect ();
#endif
}
}
rc = libusb_claim_interface (idev, ifc_no); rc = libusb_claim_interface (idev, ifc_no);
if (rc) if (rc)
{ {

View File

@ -104,6 +104,7 @@ enum cmd_and_opt_values
oDisableApplication, oDisableApplication,
oApplicationPriority, oApplicationPriority,
oEnablePinpadVarlen, oEnablePinpadVarlen,
oCompatibilityFlags,
oListenBacklog oListenBacklog
}; };
@ -172,6 +173,7 @@ static gpgrt_opt_t opts[] = {
ARGPARSE_s_s (oDisableApplication, "disable-application", "@"), ARGPARSE_s_s (oDisableApplication, "disable-application", "@"),
ARGPARSE_s_s (oApplicationPriority, "application-priority", ARGPARSE_s_s (oApplicationPriority, "application-priority",
N_("|LIST|change the application priority to LIST")), N_("|LIST|change the application priority to LIST")),
ARGPARSE_s_s (oCompatibilityFlags, "compatibility-flags", "@"),
ARGPARSE_s_i (oListenBacklog, "listen-backlog", "@"), ARGPARSE_s_i (oListenBacklog, "listen-backlog", "@"),
@ -204,6 +206,14 @@ static struct debug_flags_s debug_flags [] =
}; };
/* The list of compatibility flags. */
static struct compatibility_flags_s compatibility_flags [] =
{
{ COMPAT_CCID_NO_AUTO_DETACH, "ccid-no-auto-detach" },
{ 0, NULL }
};
/* The card driver we use by default for PC/SC. */ /* The card driver we use by default for PC/SC. */
#if defined(HAVE_W32_SYSTEM) || defined(__CYGWIN__) #if defined(HAVE_W32_SYSTEM) || defined(__CYGWIN__)
#define DEFAULT_PCSC_DRIVER "winscard.dll" #define DEFAULT_PCSC_DRIVER "winscard.dll"
@ -632,6 +642,15 @@ main (int argc, char **argv )
case oEnablePinpadVarlen: opt.enable_pinpad_varlen = 1; break; case oEnablePinpadVarlen: opt.enable_pinpad_varlen = 1; break;
case oCompatibilityFlags:
if (parse_compatibility_flags (pargs.r.ret_str, &opt.compat_flags,
compatibility_flags))
{
pargs.r_opt = ARGPARSE_INVALID_ARG;
pargs.err = ARGPARSE_PRINT_WARNING;
}
break;
case oListenBacklog: case oListenBacklog:
listen_backlog = pargs.r.ret_int; listen_backlog = pargs.r.ret_int;
break; break;

View File

@ -67,6 +67,9 @@ struct
want to use. */ want to use. */
unsigned long card_timeout; /* Disconnect after N seconds of inactivity. */ unsigned long card_timeout; /* Disconnect after N seconds of inactivity. */
int debug_allow_pin_logging; /* Allow PINs in debug output. */ int debug_allow_pin_logging; /* Allow PINs in debug output. */
/* Compatibility flags (COMPAT_FLAG_xxxx). */
unsigned int compat_flags;
} opt; } opt;
@ -92,6 +95,11 @@ struct
#define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE) #define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE)
#define DBG_READER (opt.debug & DBG_READER_VALUE) #define DBG_READER (opt.debug & DBG_READER_VALUE)
#define COMPAT_CCID_NO_AUTO_DETACH 1
struct server_local_s; struct server_local_s;
struct card_ctx_s; struct card_ctx_s;
struct app_ctx_s; struct app_ctx_s;