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

@ -29,6 +29,7 @@
#include "irp.h" #include "irp.h"
#include "devredir.h" #include "devredir.h"
#include "smartcard_pcsc.h" #include "smartcard_pcsc.h"
#include "chansrv.h"
/* /*
* TODO * TODO
@ -59,9 +60,8 @@
#define LOG_INFO 1 #define LOG_INFO 1
#define LOG_DEBUG 2 #define LOG_DEBUG 2
#ifndef LOG_LEVEL #undef LOG_LEVEL
#define LOG_LEVEL LOG_INFO #define LOG_LEVEL LOG_INFO
#endif
#define log_error(_params...) \ #define log_error(_params...) \
do \ do \
@ -86,6 +86,7 @@ do \
do \ do \
{ \ { \
if (LOG_DEBUG <= LOG_LEVEL) \ if (LOG_DEBUG <= LOG_LEVEL) \
if (2 <= 1) \
{ \ { \
g_write("[%10.10u]: SMART_CARD %s: %d : ", \ g_write("[%10.10u]: SMART_CARD %s: %d : ", \
g_time3(), __func__, __LINE__); \ g_time3(), __func__, __LINE__); \
@ -318,7 +319,7 @@ scard_check_wait_objs(void)
int APP_CC int APP_CC
scard_init(void) scard_init(void)
{ {
log_debug("init"); LOG(0, ("scard_init:"));
return scard_pcsc_init(); return scard_pcsc_init();
} }
@ -328,7 +329,7 @@ scard_init(void)
int APP_CC int APP_CC
scard_deinit(void) scard_deinit(void)
{ {
log_debug("deinit"); LOG(0, ("scard_deinit:"));
return scard_pcsc_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_lis = 0;
static struct trans *g_con = 0; /* todo, remove this */ static struct trans *g_con = 0; /* todo, remove this */
static char g_pcsclite_ipc_dir[256] = ""; static char g_pcsclite_ipc_dir[256] = "";
static char g_pcsclite_ipc_file[256] = "";
static int g_pub_file_fd = 0; 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); groups = (char *) g_malloc(bytes_groups + 1, 1);
in_uint8a(in_s, groups, bytes_groups); in_uint8a(in_s, groups, bytes_groups);
in_uint32_le(in_s, cchReaders); 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", LLOGLN(10, ("scard_process_list_readers: hContext 0x%8.8x cchReaders %d",
hContext, cchReaders)); hContext, cchReaders));
scard_send_list_readers(con, hContext, groups, cchReaders, 1); 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 int APP_CC
scard_pcsc_init(void) scard_pcsc_init(void)
{ {
char port[256];
char *home; char *home;
int disp; int disp;
int error; int error;
@ -1223,31 +1223,35 @@ scard_pcsc_init(void)
if (g_lis == 0) if (g_lis == 0)
{ {
g_lis = trans_create(2, 8192, 8192); 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"); home = g_getenv("HOME");
disp = g_display_num; disp = g_display_num;
g_snprintf(g_pcsclite_ipc_dir, 255, "%s/.pcsc%d", home, disp); g_snprintf(g_pcsclite_ipc_dir, 255, "%s/.pcsc%d", home, disp);
if (g_directory_exist(g_pcsclite_ipc_dir)) 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")); 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_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; 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) if (error != 0)
{ {
LLOGLN(0, ("scard_pcsc_init: trans_listen failed for port %s", LLOGLN(0, ("scard_pcsc_init: trans_listen failed for port %s",
port)); g_pcsclite_ipc_file));
return 1; return 1;
} }
} }
@ -1259,20 +1263,29 @@ int APP_CC
scard_pcsc_deinit(void) scard_pcsc_deinit(void)
{ {
LLOGLN(0, ("scard_pcsc_deinit:")); LLOGLN(0, ("scard_pcsc_deinit:"));
if (g_lis != 0) if (g_lis != 0)
{ {
trans_delete(g_lis); trans_delete(g_lis);
g_lis = 0; g_lis = 0;
}
if (g_pub_file_fd != 0)
{
g_file_close(g_pub_file_fd); g_file_close(g_pub_file_fd);
g_pub_file_fd = 0; 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")); LLOGLN(0, ("scard_pcsc_deinit: g_remove_dir failed"));
} }
g_pcsclite_ipc_dir[0] = 0; g_pcsclite_ipc_dir[0] = 0;
} }
return 0; return 0;
} }

@ -225,7 +225,7 @@ sound_process_format(int aindex, int wFormatTag, int nChannels,
{ {
g_current_client_format_index = aindex; g_current_client_format_index = aindex;
g_current_server_format_index = lindex; g_current_server_format_index = lindex;
} }
} }
#endif #endif
return 0; return 0;
@ -576,6 +576,8 @@ sound_init(void)
int APP_CC int APP_CC
sound_deinit(void) sound_deinit(void)
{ {
LOG(0, ("sound_deinit:"));
if (g_audio_l_trans != 0) if (g_audio_l_trans != 0)
{ {
trans_delete(g_audio_l_trans); trans_delete(g_audio_l_trans);

Loading…
Cancel
Save