allow selecting smartcard emulator at runtime rather than link time
This commit is contained in:
parent
9f967b4942
commit
c691ef9c8d
@ -157,7 +157,7 @@ message(STATUS "Git Revision ${GIT_REVISION}")
|
||||
set(FREERDP_MAJOR_DIR "freerdp${FREERDP_VERSION_MAJOR}")
|
||||
set(FREERDP_INCLUDE_DIR "include/${FREERDP_MAJOR_DIR}/")
|
||||
|
||||
option(WITH_SMARTCARD_EMULATE "Emulate smartcards instead of redirecting readers" OFF)
|
||||
option(WITH_SMARTCARD_EMULATE "Emulate smartcards instead of redirecting readers" ON)
|
||||
if (WITH_SMARTCARD_EMULATE)
|
||||
add_definitions(-DWITH_SMARTCARD_EMULATE)
|
||||
find_package(ZLIB REQUIRED)
|
||||
@ -585,10 +585,6 @@ endif()
|
||||
set(WAYLAND_FEATURE_PURPOSE "Wayland")
|
||||
set(WAYLAND_FEATURE_DESCRIPTION "Wayland client")
|
||||
|
||||
set(ZLIB_FEATURE_TYPE "REQUIRED")
|
||||
set(ZLIB_FEATURE_PURPOSE "compression")
|
||||
set(ZLIB_FEATURE_DESCRIPTION "data compression")
|
||||
|
||||
set(OPENSSL_FEATURE_TYPE "REQUIRED")
|
||||
set(OPENSSL_FEATURE_PURPOSE "cryptography")
|
||||
set(OPENSSL_FEATURE_DESCRIPTION "encryption, certificate validation, hashing functions")
|
||||
@ -671,7 +667,6 @@ set(SOXR_FEATURE_DESCRIPTION "SOX audio resample library")
|
||||
|
||||
if(WIN32)
|
||||
set(WAYLAND_FEATURE_TYPE "DISABLED")
|
||||
set(ZLIB_FEATURE_TYPE "OPTIONAL")
|
||||
set(OSS_FEATURE_TYPE "DISABLED")
|
||||
set(ALSA_FEATURE_TYPE "DISABLED")
|
||||
set(SNDIO_FEATURE_TYPE "DISABLED")
|
||||
@ -727,7 +722,6 @@ endif()
|
||||
|
||||
find_feature(Wayland ${WAYLAND_FEATURE_TYPE} ${WAYLAND_FEATURE_PURPOSE} ${WAYLAND_FEATURE_DESCRIPTION})
|
||||
|
||||
find_feature(ZLIB ${ZLIB_FEATURE_TYPE} ${ZLIB_FEATURE_PURPOSE} ${ZLIB_FEATURE_DESCRIPTION})
|
||||
find_feature(OpenSSL ${OPENSSL_FEATURE_TYPE} ${OPENSSL_FEATURE_PURPOSE} ${OPENSSL_FEATURE_DESCRIPTION})
|
||||
find_feature(MbedTLS ${MBEDTLS_FEATURE_TYPE} ${MBEDTLS_FEATURE_PURPOSE} ${MBEDTLS_FEATURE_DESCRIPTION})
|
||||
find_feature(OpenSLES ${OPENSLES_FEATURE_TYPE} ${OPENSLES_FEATURE_PURPOSE} ${OPENSLES_FEATURE_DESCRIPTION})
|
||||
|
@ -35,10 +35,6 @@
|
||||
#include <freerdp/utils/smartcard_operations.h>
|
||||
#include <freerdp/utils/smartcard_call.h>
|
||||
|
||||
#if defined(WITH_SMARTCARD_EMULATE)
|
||||
#include <freerdp/emulate/scard/smartcard_emulate.h>
|
||||
#endif
|
||||
|
||||
#define TAG CHANNELS_TAG("smartcard.client")
|
||||
|
||||
typedef struct
|
||||
|
@ -47,15 +47,17 @@
|
||||
#include <freerdp/emulate/scard/smartcard_emulate.h>
|
||||
|
||||
#define str(x) #x
|
||||
#define wrap(ctx, fkt, ...) Emulate_##fkt(ctx->emulation, ##__VA_ARGS__)
|
||||
#define wrap(ctx, fkt, ...) \
|
||||
ctx->useEmulatedCard ? Emulate_##fkt(ctx->emulation, ##__VA_ARGS__) : fkt(__VA_ARGS__)
|
||||
#else
|
||||
#define wrap(ctx, fkt, ...) fkt(__VA_ARGS__)
|
||||
#define wrap(ctx, fkt, ...) ctx->useEmulatedCard ? SCARD_F_INTERNAL_ERROR : fkt(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#define SCARD_MAX_TIMEOUT 60000
|
||||
|
||||
struct s_scard_call_context
|
||||
{
|
||||
BOOL useEmulatedCard;
|
||||
HANDLE StartedEvent;
|
||||
wLinkedList* names;
|
||||
wHashTable* rgSCardContextList;
|
||||
@ -1838,11 +1840,21 @@ scard_call_context* smartcard_call_context_new(const rdpSettings* settings)
|
||||
if (!ctx->names)
|
||||
goto fail;
|
||||
|
||||
#if defined(WITH_SMARTCARD_EMULATE)
|
||||
ctx->useEmulatedCard = settings->SmartcardEmulation;
|
||||
#endif
|
||||
|
||||
if (ctx->useEmulatedCard)
|
||||
{
|
||||
#if defined(WITH_SMARTCARD_EMULATE)
|
||||
ctx->emulation = Emulate_New(settings);
|
||||
if (!ctx->emulation)
|
||||
goto fail;
|
||||
#else
|
||||
WLog_ERR(TAG, "Smartcard emulation requested, but not supported!");
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
|
||||
ctx->rgSCardContextList = HashTable_New(FALSE);
|
||||
if (!ctx->rgSCardContextList)
|
||||
@ -1870,9 +1882,17 @@ void smartcard_call_context_free(scard_call_context* ctx)
|
||||
{
|
||||
wrap(ctx, SCardReleaseStartedEvent);
|
||||
}
|
||||
#if defined(WITH_SMARTCARD_EMULATE)
|
||||
|
||||
if (ctx->useEmulatedCard)
|
||||
{
|
||||
#ifdef WITH_SMARTCARD_EMULATE
|
||||
if (ctx->emulation)
|
||||
{
|
||||
Emulate_Free(ctx->emulation);
|
||||
ctx->emulation = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
HashTable_Free(ctx->rgSCardContextList);
|
||||
CloseHandle(ctx->stopEvent);
|
||||
free(ctx);
|
||||
@ -1936,10 +1956,11 @@ BOOL smartcard_call_is_configured(scard_call_context* ctx)
|
||||
WINPR_ASSERT(ctx);
|
||||
|
||||
#if defined(WITH_SMARTCARD_EMULATE)
|
||||
if (ctx->useEmulatedCard)
|
||||
return Emulate_IsConfigured(ctx->emulation);
|
||||
#else
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL smartcard_call_context_signal_stop(scard_call_context* ctx, BOOL reset)
|
||||
|
Loading…
Reference in New Issue
Block a user