diff --git a/configure.ac b/configure.ac index 038dd350..d815ab17 100644 --- a/configure.ac +++ b/configure.ac @@ -484,17 +484,19 @@ if test "${enable_pcsc}" = "yes"; then if test "${with_pcsc_provider}" = "detect"; then case "${host}" in *-*-darwin*) - with_pcsc_provider="${full_usrlibdir}/libpcsclite.so" + DEFAULT_PCSC_PROVIDER="${full_usrlibdir}/libpcsclite.so" ;; *-mingw32*|*-winnt*|*-cygwin*) - with_pcsc_provider="winscard.dll" + DEFAULT_PCSC_PROVIDER="winscard.dll" ;; *) - with_pcsc_provider="${full_usrlibdir}/libpcsclite.so" + DEFAULT_PCSC_PROVIDER="${full_usrlibdir}/libpcsclite.so" ;; esac + else + DEFAULT_PCSC_PROVIDER="${with_pcsc_provider}" fi - AC_DEFINE_UNQUOTED([PCSC_DEFAULT_LIBRARY_NAME], ["${with_pcsc_provider}"], [Default PC/SC library]) + AC_DEFINE_UNQUOTED([DEFAULT_PCSC_PROVIDER], ["${DEFAULT_PCSC_PROVIDER}"], [Default PC/SC provider]) fi dnl AM_PATH_LIBASSUAN([MINIMUM-VERSION, @@ -533,7 +535,7 @@ if test "${enable_openct}" = "yes"; then OPTIONAL_OPENCT_CFLAGS="${OPENCT_CFLAGS}" OPTIONAL_OPENCT_LIBS="${OPENCT_LIBS}" fi -test "${enable_pcsc}" = "yes" && OPENSC_FEATURES="${OPENSC_FEATURES} pcsc" +test "${enable_pcsc}" = "yes" && OPENSC_FEATURES="${OPENSC_FEATURES} pcsc(${DEFAULT_PCSC_PROVIDER})" test "${enable_nsplugin}" = "yes" && OPENSC_FEATURES="${OPENSC_FEATURES} nsplugin" AC_DEFINE_UNQUOTED([OPENSC_ETC_PATH], ["${full_sysconfdir}"], [etc path for libopensc]) @@ -558,6 +560,7 @@ AC_SUBST([OPENSC_LT_REVISION]) AC_SUBST([OPENSC_LT_AGE]) AC_SUBST([OPENSC_LT_OLDEST]) AC_SUBST([WIN_LIBPREFIX]) +AC_SUBST([DEFAULT_PCSC_PROVIDER]) AC_SUBST([OPTIONAL_ZLIB_CFLAGS]) AC_SUBST([OPTIONAL_ZLIB_LIBS]) AC_SUBST([OPTIONAL_READLINE_CFLAGS]) @@ -637,7 +640,7 @@ PC/SC support: ${enable_pcsc} OpenCT support: ${enable_openct} NSPlugin support: ${enable_nsplugin} -PC/SC default provider: ${with_pcsc_provider} +PC/SC default provider: ${DEFAULT_PCSC_PROVIDER} pinentry: ${with_pinentry} Host: ${host} diff --git a/etc/Makefile.am b/etc/Makefile.am index c69f641c..c6b6d57e 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -7,7 +7,10 @@ dist_noinst_DATA = opensc.conf.in nodist_noinst_DATA = opensc.conf .in: - sed -e "s|@pkgdatadir[@]|$(pkgdatadir)|g" < $^ > $@ + sed \ + -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \ + -e 's|@DEFAULT_PCSC_PROVIDER[@]|$(DEFAULT_PCSC_PROVIDER)|g' \ + < $^ > $@ sysconf_DATA=#required in order to create dir install-exec-hook: install-sysconfDATA opensc.conf diff --git a/etc/opensc.conf.in b/etc/opensc.conf.in index 5bd701a4..22737a15 100644 --- a/etc/opensc.conf.in +++ b/etc/opensc.conf.in @@ -88,9 +88,9 @@ app default { # Default: false # enable_pinpad = true; # - # Use specific pcsc library. - # Default: system - # library_name = /usr/lib/libpcsclite.so + # Use specific pcsc provider. + # Default: @DEFAULT_PCSC_PROVIDER@ + # provider_library = @DEFAULT_PCSC_PROVIDER@ } # options for openct support diff --git a/src/libopensc/reader-pcsc.c b/src/libopensc/reader-pcsc.c index eed9a4d0..d3e20b58 100644 --- a/src/libopensc/reader-pcsc.c +++ b/src/libopensc/reader-pcsc.c @@ -67,7 +67,7 @@ struct pcsc_global_private_data { int connect_exclusive; int connect_reset; int transaction_reset; - const char *library_name; + const char *provider_library; lt_dlhandle dlhandle; SCardEstablishContext_t SCardEstablishContext; SCardReleaseContext_t SCardReleaseContext; @@ -752,7 +752,7 @@ static int pcsc_init(sc_context_t *ctx, void **reader_data) gpriv->connect_exclusive = 0; gpriv->transaction_reset = 0; gpriv->enable_pinpad = 0; - gpriv->library_name = PCSC_DEFAULT_LIBRARY_NAME; + gpriv->provider_library = DEFAULT_PCSC_PROVIDER; conf_block = sc_get_conf_block(ctx, "reader_driver", "pcsc", 1); if (conf_block) { @@ -764,11 +764,11 @@ static int pcsc_init(sc_context_t *ctx, void **reader_data) scconf_get_bool(conf_block, "transaction_reset", gpriv->transaction_reset); gpriv->enable_pinpad = scconf_get_bool(conf_block, "enable_pinpad", gpriv->enable_pinpad); - gpriv->library_name = - scconf_get_str(conf_block, "library_name", gpriv->library_name); + gpriv->provider_library = + scconf_get_str(conf_block, "provider_library", gpriv->provider_library); } - gpriv->dlhandle = lt_dlopen(gpriv->library_name); + gpriv->dlhandle = lt_dlopen(gpriv->provider_library); if (gpriv->dlhandle == NULL) { ret = SC_ERROR_CANNOT_LOAD_MODULE; goto out;