chansrv: handle smartcard session reconnect and some logging changes

ulab-next
Jay Sorg 11 years ago
parent 16deb72678
commit ef51e44119

@ -363,7 +363,7 @@ clipboard_init(void)
int ver_min;
Status st;
log_debug("xrdp-chansrv: in clipboard_init");
LOG(0, ("clipboard_init:"));
if (g_clip_up)
{
@ -507,7 +507,7 @@ clipboard_init(void)
int APP_CC
clipboard_deinit(void)
{
log_debug("clipboard_deinit:");
LOG(0, ("clipboard_deinit:"));
if (g_wnd != 0)
{
XDestroyWindow(g_display, g_wnd);

@ -29,6 +29,7 @@
#include "irp.h"
#include "devredir.h"
#include "smartcard_pcsc.h"
#include "chansrv.h"
/*
* TODO
@ -59,9 +60,8 @@
#define LOG_INFO 1
#define LOG_DEBUG 2
#ifndef LOG_LEVEL
#undef LOG_LEVEL
#define LOG_LEVEL LOG_INFO
#endif
#define log_error(_params...) \
do \
@ -86,6 +86,7 @@ do \
do \
{ \
if (LOG_DEBUG <= LOG_LEVEL) \
if (2 <= 1) \
{ \
g_write("[%10.10u]: SMART_CARD %s: %d : ", \
g_time3(), __func__, __LINE__); \
@ -318,7 +319,7 @@ scard_check_wait_objs(void)
int APP_CC
scard_init(void)
{
log_debug("init");
LOG(0, ("scard_init:"));
return scard_pcsc_init();
}
@ -328,7 +329,7 @@ scard_init(void)
int APP_CC
scard_deinit(void)
{
log_debug("deinit");
LOG(0, ("scard_deinit:"));
return scard_pcsc_deinit();
}

@ -83,6 +83,7 @@ static struct pcsc_client *g_tail = 0;
static struct trans *g_lis = 0;
static struct trans *g_con = 0; /* todo, remove this */
static char g_pcsclite_ipc_dir[256] = "";
static char g_pcsclite_ipc_file[256] = "";
static int g_pub_file_fd = 0;
/*****************************************************************************/
@ -255,7 +256,7 @@ scard_process_list_readers(struct trans *con, struct stream *in_s)
groups = (char *) g_malloc(bytes_groups + 1, 1);
in_uint8a(in_s, groups, bytes_groups);
in_uint32_le(in_s, cchReaders);
g_xrdp_pcsc_extra1 = g_xrdp_pcsc_extra1 = cchReaders;
g_xrdp_pcsc_extra1 = cchReaders;
LLOGLN(10, ("scard_process_list_readers: hContext 0x%8.8x cchReaders %d",
hContext, cchReaders));
scard_send_list_readers(con, hContext, groups, cchReaders, 1);
@ -1214,7 +1215,6 @@ my_pcsc_trans_conn_in(struct trans *trans, struct trans *new_trans)
int APP_CC
scard_pcsc_init(void)
{
char port[256];
char *home;
int disp;
int error;
@ -1223,31 +1223,35 @@ scard_pcsc_init(void)
if (g_lis == 0)
{
g_lis = trans_create(2, 8192, 8192);
//g_snprintf(g_pcsclite_ipc_dir, 255, "/tmp/.xrdp/pcsc%d", g_display_num);
home = g_getenv("HOME");
disp = g_display_num;
g_snprintf(g_pcsclite_ipc_dir, 255, "%s/.pcsc%d", home, disp);
if (g_directory_exist(g_pcsclite_ipc_dir))
{
if (g_remove_dir(g_pcsclite_ipc_dir) != 0)
if (!g_remove_dir(g_pcsclite_ipc_dir))
{
LLOGLN(0, ("scard_pcsc_init: g_remove_dir failed"));
}
}
if (!g_create_dir(g_pcsclite_ipc_dir))
if (!g_directory_exist(g_pcsclite_ipc_dir))
{
LLOGLN(0, ("scard_pcsc_init: g_create_dir failed"));
if (!g_create_dir(g_pcsclite_ipc_dir))
{
if (!g_directory_exist(g_pcsclite_ipc_dir))
{
LLOGLN(0, ("scard_pcsc_init: g_create_dir failed"));
}
}
}
g_chmod_hex(g_pcsclite_ipc_dir, 0x1777);
g_snprintf(port, 255, "%s/pcscd.comm", g_pcsclite_ipc_dir);
g_snprintf(g_pcsclite_ipc_file, 255, "%s/pcscd.comm", g_pcsclite_ipc_dir);
g_lis->trans_conn_in = my_pcsc_trans_conn_in;
error = trans_listen(g_lis, port);
error = trans_listen(g_lis, g_pcsclite_ipc_file);
if (error != 0)
{
LLOGLN(0, ("scard_pcsc_init: trans_listen failed for port %s",
port));
g_pcsclite_ipc_file));
return 1;
}
}
@ -1259,20 +1263,29 @@ int APP_CC
scard_pcsc_deinit(void)
{
LLOGLN(0, ("scard_pcsc_deinit:"));
if (g_lis != 0)
{
trans_delete(g_lis);
g_lis = 0;
}
if (g_pub_file_fd != 0)
{
g_file_close(g_pub_file_fd);
g_pub_file_fd = 0;
}
if (g_remove_dir(g_pcsclite_ipc_dir) != 0)
if (g_pcsclite_ipc_dir[0] != 0)
{
g_file_delete(g_pcsclite_ipc_file);
if (!g_remove_dir(g_pcsclite_ipc_dir))
{
LLOGLN(0, ("scard_pcsc_deinit: g_remove_dir failed"));
}
g_pcsclite_ipc_dir[0] = 0;
}
return 0;
}

@ -576,6 +576,8 @@ sound_init(void)
int APP_CC
sound_deinit(void)
{
LOG(0, ("sound_deinit:"));
if (g_audio_l_trans != 0)
{
trans_delete(g_audio_l_trans);

Loading…
Cancel
Save