Fix scard logon

This commit is contained in:
Rostislav Kondratenko 2018-04-03 20:51:34 +03:00 committed by Alexander Zakharov
parent 567b1f7432
commit 2abd25ae2a
3 changed files with 48 additions and 0 deletions

View File

@ -360,6 +360,7 @@ void scard_unlock(int lock);
int scard_enum_devices(uint32 * id, char *optarg); int scard_enum_devices(uint32 * id, char *optarg);
void scardSetInfo(uint32 epoch, uint32 device, uint32 id, uint32 bytes_out); void scardSetInfo(uint32 epoch, uint32 device, uint32 id, uint32 bytes_out);
void scard_reset_state(); void scard_reset_state();
void scard_release_all_contexts(void);
/* *INDENT-OFF* */ /* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus

24
rdpdr.c
View File

@ -879,6 +879,30 @@ rdpdr_process(STREAM s)
g_client_id = 0x815ed39d; /* IP address (use 127.0.0.1) 0x815ed39d */ g_client_id = 0x815ed39d; /* IP address (use 127.0.0.1) 0x815ed39d */
g_epoch++; g_epoch++;
#if WITH_SCARD
/*
* We need to release all SCARD contexts to end all
* current transactions and pending calls
*/
scard_release_all_contexts();
/*
* According to [MS-RDPEFS] 3.2.5.1.2:
*
* If this packet appears after a sequence of other packets,
* it is a signal that the server has reconnected to a new session
* and the whole sequence has been reset. The client MUST treat
* this packet as the beginning of a new sequence.
* The client MUST also cancel all outstanding requests and release
* previous references to all devices.
*
* If any problem arises in the future, please, pay attention to the
* "If this packet appears after a sequence of other packets" part
*
*/
#endif
rdpdr_send_client_announce_reply(); rdpdr_send_client_announce_reply();
rdpdr_send_client_name_request(); rdpdr_send_client_name_request();
break; break;

23
scard.c
View File

@ -4,6 +4,7 @@
Copyright (C) Alexi Volkov <alexi@myrealbox.com> 2006 Copyright (C) Alexi Volkov <alexi@myrealbox.com> 2006
Copyright 2010-2013 Pierre Ossman <ossman@cendio.se> for Cendio AB Copyright 2010-2013 Pierre Ossman <ossman@cendio.se> for Cendio AB
Copyright 2011-2017 Henrik Andersson <hean01@cendio.se> for Cendio AB Copyright 2011-2017 Henrik Andersson <hean01@cendio.se> for Cendio AB
Copyright 2015 Rostislav Kondratenko <r.kondratenk@wwpass.com>
Copyright 2017 Karl Mikaelsson <derfian@cendio.se> for Cendio AB Copyright 2017 Karl Mikaelsson <derfian@cendio.se> for Cendio AB
Copyright 2018 Alexander Zakharov <uglym8@gmail.com> Copyright 2018 Alexander Zakharov <uglym8@gmail.com>
@ -2752,3 +2753,25 @@ scard_reset_state()
queueFirst = queueLast = NULL; queueFirst = queueLast = NULL;
} }
void scard_release_all_contexts(void)
{
_scard_handle_list_t *item, *next;
item = g_scard_handle_list;
while (item)
{
/* Cancelling ScardGetStatusChange calls */
SCardCancel(item->handle);
/* releasing context to end all transactions on it */
SCardReleaseContext(item->handle);
next = item->next;
xfree(item);
item = next;
}
g_scard_handle_list = NULL;
}