diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2012-06-04 01:11:16 -0700 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2012-06-04 01:11:16 -0700 |
commit | 5cd7e29a9fa69c8b1b6c3a3ca8ebf8a9966a2492 (patch) | |
tree | a47661f16bcd913652a2a6d671e71884a79046f8 /sesman | |
parent | af1b96b3d2dd4c7fb3d15b278e2fbbb6bcc9065e (diff) | |
parent | 4d4ebbf3632bed609b41a9d36969c08d36791417 (diff) | |
download | xrdp-proprietary-5cd7e29a9fa69c8b1b6c3a3ca8ebf8a9966a2492.tar.gz xrdp-proprietary-5cd7e29a9fa69c8b1b6c3a3ca8ebf8a9966a2492.zip |
Merge remote branch 'syslog3/syslog3'
Diffstat (limited to 'sesman')
-rw-r--r-- | sesman/access.c | 26 | ||||
-rw-r--r-- | sesman/chansrv/chansrv.c | 81 | ||||
-rw-r--r-- | sesman/chansrv/clipboard.c | 147 | ||||
-rw-r--r-- | sesman/config.c | 43 | ||||
-rw-r--r-- | sesman/config.h | 5 | ||||
-rw-r--r-- | sesman/env.c | 6 | ||||
-rw-r--r-- | sesman/libscp/libscp_connection.c | 4 | ||||
-rw-r--r-- | sesman/libscp/libscp_init.c | 10 | ||||
-rw-r--r-- | sesman/libscp/libscp_init.h | 2 | ||||
-rw-r--r-- | sesman/libscp/libscp_session.c | 48 | ||||
-rw-r--r-- | sesman/libscp/libscp_tcp.c | 4 | ||||
-rw-r--r-- | sesman/libscp/libscp_v0.c | 44 | ||||
-rw-r--r-- | sesman/libscp/libscp_v1c_mng.c | 38 | ||||
-rw-r--r-- | sesman/libscp/libscp_v1s.c | 80 | ||||
-rw-r--r-- | sesman/libscp/libscp_v1s_mng.c | 18 | ||||
-rw-r--r-- | sesman/lock.c | 16 | ||||
-rw-r--r-- | sesman/scp.c | 20 | ||||
-rw-r--r-- | sesman/scp_v0.c | 14 | ||||
-rw-r--r-- | sesman/scp_v1.c | 36 | ||||
-rw-r--r-- | sesman/scp_v1_mng.c | 22 | ||||
-rw-r--r-- | sesman/sesman.c | 30 | ||||
-rw-r--r-- | sesman/sesman.ini | 2 | ||||
-rw-r--r-- | sesman/session.c | 112 | ||||
-rw-r--r-- | sesman/sig.c | 36 | ||||
-rw-r--r-- | sesman/thread.c | 30 | ||||
-rw-r--r-- | sesman/tools/sesadmin.c | 8 | ||||
-rw-r--r-- | sesman/tools/sestest.c | 2 | ||||
-rw-r--r-- | sesman/verify_user.c | 14 |
28 files changed, 476 insertions, 422 deletions
diff --git a/sesman/access.c b/sesman/access.c index f4bfd30a..0037de3f 100644 --- a/sesman/access.c +++ b/sesman/access.c @@ -38,33 +38,33 @@ access_login_allowed(char* user) if ((0 == g_strncmp(user, "root", 5)) && (0 == g_cfg->sec.allow_root)) { - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, + log_message(LOG_LEVEL_WARNING, "ROOT login attempted, but root login is disabled"); return 0; } if (0 == g_cfg->sec.ts_users_enable) { - LOG_DBG(&(g_cfg->log), "Terminal Server Users group is disabled, allowing authentication", + LOG_DBG("Terminal Server Users group is disabled, allowing authentication", 1); return 1; } if (0 != g_getuser_info(user, &gid, 0, 0, 0, 0)) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "Cannot read user info! - login denied"); + log_message(LOG_LEVEL_ERROR, "Cannot read user info! - login denied"); return 0; } if (g_cfg->sec.ts_users == gid) { - LOG_DBG(&(g_cfg->log), "ts_users is user's primary group"); + LOG_DBG("ts_users is user's primary group"); return 1; } if (0 != g_check_user_in_group(user, g_cfg->sec.ts_users, &ok)) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "Cannot read group info! - login denied"); + log_message(LOG_LEVEL_ERROR, "Cannot read group info! - login denied"); return 0; } @@ -73,7 +73,7 @@ access_login_allowed(char* user) return 1; } - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "login denied for user %s", user); + log_message(LOG_LEVEL_INFO, "login denied for user %s", user); return 0; } @@ -87,33 +87,33 @@ access_login_mng_allowed(char* user) if ((0 == g_strncmp(user, "root", 5)) && (0 == g_cfg->sec.allow_root)) { - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, + log_message(LOG_LEVEL_WARNING, "[MNG] ROOT login attempted, but root login is disabled"); return 0; } if (0 == g_cfg->sec.ts_admins_enable) { - LOG_DBG(&(g_cfg->log), "[MNG] Terminal Server Admin group is disabled, allowing authentication", - 1); + LOG_DBG("[MNG] Terminal Server Admin group is disabled," + "allowing authentication",1); return 1; } if (0 != g_getuser_info(user, &gid, 0, 0, 0, 0)) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "[MNG] Cannot read user info! - login denied"); + log_message(LOG_LEVEL_ERROR, "[MNG] Cannot read user info! - login denied"); return 0; } if (g_cfg->sec.ts_admins == gid) { - LOG_DBG(&(g_cfg->log), "[MNG] ts_users is user's primary group"); + LOG_DBG("[MNG] ts_users is user's primary group"); return 1; } if (0 != g_check_user_in_group(user, g_cfg->sec.ts_admins, &ok)) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "[MNG] Cannot read group info! - login denied"); + log_message(LOG_LEVEL_ERROR, "[MNG] Cannot read group info! - login denied"); return 0; } @@ -122,7 +122,7 @@ access_login_mng_allowed(char* user) return 1; } - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "[MNG] login denied for user %s", user); + log_message(LOG_LEVEL_INFO, "[MNG] login denied for user %s", user); return 0; } diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index f2ca961d..91765749 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -29,6 +29,7 @@ #include "list.h" #include "file.h" #include "file_loc.h" +#include "log.h" static struct trans* g_lis_trans = 0; static struct trans* g_con_trans = 0; @@ -107,7 +108,7 @@ send_init_response_message(void) { struct stream * s = (struct stream *)NULL; - LOG(1, ("send_init_response_message:")); + log_message(LOG_LEVEL_INFO,"send_init_response_message:"); s = trans_get_out_s(g_con_trans, 8192); if (s == 0) { @@ -128,7 +129,7 @@ send_channel_setup_response_message(void) { struct stream * s = (struct stream *)NULL; - LOG(10, ("send_channel_setup_response_message:")); + log_message(LOG_LEVEL_DEBUG, "send_channel_setup_response_message:"); s = trans_get_out_s(g_con_trans, 8192); if (s == 0) { @@ -149,7 +150,7 @@ send_channel_data_response_message(void) { struct stream * s = (struct stream *)NULL; - LOG(10, ("send_channel_data_response_message:")); + log_message(LOG_LEVEL_DEBUG, "send_channel_data_response_message:"); s = trans_get_out_s(g_con_trans, 8192); if (s == 0) { @@ -168,7 +169,7 @@ send_channel_data_response_message(void) static int APP_CC process_message_init(struct stream* s) { - LOG(10, ("process_message_init:")); + log_message(LOG_LEVEL_DEBUG,"process_message_init:"); return send_init_response_message(); } @@ -189,9 +190,9 @@ process_message_channel_setup(struct stream* s) g_cliprdr_chan_id = -1; g_rdpsnd_chan_id = -1; g_rdpdr_chan_id = -1; - LOG(10, ("process_message_channel_setup:")); + log_message(LOG_LEVEL_DEBUG, "process_message_channel_setup:"); in_uint16_le(s, num_chans); - LOG(10, ("process_message_channel_setup: num_chans %d", num_chans)); + log_message(LOG_LEVEL_DEBUG,"process_message_channel_setup: num_chans %d", num_chans); for (index = 0; index < num_chans; index++) { ci = &(g_chan_items[g_num_chan_items]); @@ -199,8 +200,8 @@ process_message_channel_setup(struct stream* s) in_uint8a(s, ci->name, 8); in_uint16_le(s, ci->id); in_uint16_le(s, ci->flags); - LOG(10, ("process_message_channel_setup: chan name '%s' " - "id %d flags %8.8x", ci->name, ci->id, ci->flags)); + log_message(LOG_LEVEL_DEBUG, "process_message_channel_setup: chan name '%s' " + "id %d flags %8.8x", ci->name, ci->id, ci->flags); if (g_strcasecmp(ci->name, "cliprdr") == 0) { g_cliprdr_index = g_num_chan_items; @@ -249,8 +250,8 @@ process_message_channel_data(struct stream* s) in_uint16_le(s, chan_flags); in_uint16_le(s, length); in_uint32_le(s, total_length); - LOG(10, ("process_message_channel_data: chan_id %d " - "chan_flags %d", chan_id, chan_flags)); + log_message(LOG_LEVEL_DEBUG,"process_message_channel_data: chan_id %d " + "chan_flags %d", chan_id, chan_flags); rv = send_channel_data_response_message(); if (rv == 0) { @@ -321,8 +322,8 @@ process_message(void) rv = process_message_channel_data_response(s); break; default: - LOG(0, ("process_message: error in process_message " - "unknown msg %d", id)); + log_message(LOG_LEVEL_ERROR, "process_message: error in process_message ", + "unknown msg %d", id); break; } if (rv != 0) @@ -354,7 +355,7 @@ my_trans_data_in(struct trans* trans) { return 1; } - LOG(10, ("my_trans_data_in:")); + log_message(LOG_LEVEL_DEBUG,"my_trans_data_in:"); s = trans_get_in_s(trans); in_uint32_le(s, id); in_uint32_le(s, size); @@ -387,7 +388,7 @@ my_trans_conn_in(struct trans* trans, struct trans* new_trans) { return 1; } - LOG(10, ("my_trans_conn_in:")); + log_message(LOG_LEVEL_DEBUG, "my_trans_conn_in:"); g_con_trans = new_trans; g_con_trans->trans_data_in = my_trans_data_in; g_con_trans->header_size = 8; @@ -422,7 +423,7 @@ setup_listen(void) error = trans_listen(g_lis_trans, port); if (error != 0) { - LOG(0, ("setup_listen: trans_listen failed for port %s", port)); + log_message(LOG_LEVEL_ERROR, "setup_listen: trans_listen failed for port %s", port); return 1; } return 0; @@ -438,7 +439,7 @@ channel_thread_loop(void* in_val) int error = 0; THREAD_RV rv = 0; - LOG(1, ("channel_thread_loop: thread start")); + log_message(LOG_LEVEL_INFO, "channel_thread_loop: thread start"); rv = 0; error = setup_listen(); if (error == 0) @@ -452,7 +453,7 @@ channel_thread_loop(void* in_val) { if (g_is_wait_obj_set(g_term_event)) { - LOG(0, ("channel_thread_loop: g_term_event set")); + log_message(LOG_LEVEL_INFO, "channel_thread_loop: g_term_event set"); clipboard_deinit(); sound_deinit(); dev_redir_deinit(); @@ -462,15 +463,15 @@ channel_thread_loop(void* in_val) { if (trans_check_wait_objs(g_lis_trans) != 0) { - LOG(0, ("channel_thread_loop: trans_check_wait_objs error")); + log_message(LOG_LEVEL_INFO, "channel_thread_loop: trans_check_wait_objs error"); } } if (g_con_trans != 0) { if (trans_check_wait_objs(g_con_trans) != 0) { - LOG(0, ("channel_thread_loop: " - "trans_check_wait_objs error resetting")); + log_message(LOG_LEVEL_INFO, "channel_thread_loop: " + "trans_check_wait_objs error resetting"); clipboard_deinit(); sound_deinit(); dev_redir_deinit(); @@ -503,7 +504,7 @@ channel_thread_loop(void* in_val) g_lis_trans = 0; trans_delete(g_con_trans); g_con_trans = 0; - LOG(0, ("channel_thread_loop: thread stop")); + log_message(LOG_LEVEL_INFO, "channel_thread_loop: thread stop"); g_set_wait_obj(g_thread_done_event); return rv; } @@ -512,7 +513,7 @@ channel_thread_loop(void* in_val) void DEFAULT_CC term_signal_handler(int sig) { - LOG(1, ("term_signal_handler: got signal %d", sig)); + log_message(LOG_LEVEL_INFO,"term_signal_handler: got signal %d", sig); g_set_wait_obj(g_term_event); } @@ -520,7 +521,7 @@ term_signal_handler(int sig) void DEFAULT_CC nil_signal_handler(int sig) { - LOG(1, ("nil_signal_handler: got signal %d", sig)); + log_message(LOG_LEVEL_INFO, "nil_signal_handler: got signal %d", sig); g_set_wait_obj(g_term_event); } @@ -636,11 +637,31 @@ main(int argc, char** argv) int pid = 0; char text[256] = ""; char* display_text = (char *)NULL; + enum logReturns error ; + char cfg_file[256]; g_init("xrdp-chansrv"); /* os_calls */ read_ini(); pid = g_getpid(); - LOG(1, ("main: app started pid %d(0x%8.8x)", pid, pid)); + + /* starting logging subsystem */ + g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH); + error = log_start(cfg_file,"XRDP-Chansrv"); + if (error != LOG_STARTUP_OK) + { + char buf[256] ; + switch (error) + { + case LOG_ERROR_MALLOC: + g_printf("error on malloc. cannot start logging. quitting.\n"); + break; + case LOG_ERROR_FILE_OPEN: + g_printf("error opening log file [%s]. quitting.\n", getLogFile(buf,255)); + break; + } + g_exit(1); + } + log_message(LOG_LEVEL_ALWAYS,"main: app started pid %d(0x%8.8x)", pid, pid); /* set up signal handler */ g_signal_kill(term_signal_handler); /* SIGKILL */ @@ -648,14 +669,14 @@ main(int argc, char** argv) g_signal_user_interrupt(term_signal_handler); /* SIGINT */ g_signal_pipe(nil_signal_handler); /* SIGPIPE */ display_text = g_getenv("DISPLAY"); - LOG(1, ("main: DISPLAY env var set to %s", display_text)); + log_message(LOG_LEVEL_INFO, "main: DISPLAY env var set to %s", display_text); get_display_num_from_display(display_text); if (g_display_num == 0) { - LOG(0, ("main: error, display is zero")); + log_message(LOG_LEVEL_ERROR, "main: error, display is zero"); return 1; } - LOG(1, ("main: using DISPLAY %d", g_display_num)); + log_message(LOG_LEVEL_INFO,"main: using DISPLAY %d", g_display_num); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_main_term", pid); g_term_event = g_create_wait_obj(text); g_snprintf(text, 255, "xrdp_chansrv_%8.8x_thread_done", pid); @@ -665,7 +686,7 @@ main(int argc, char** argv) { if (g_obj_wait(&g_term_event, 1, 0, 0, 0) != 0) { - LOG(0, ("main: error, g_obj_wait failed")); + log_message(LOG_LEVEL_ERROR, "main: error, g_obj_wait failed"); break; } } @@ -674,13 +695,13 @@ main(int argc, char** argv) /* wait for thread to exit */ if (g_obj_wait(&g_thread_done_event, 1, 0, 0, 0) != 0) { - LOG(0, ("main: error, g_obj_wait failed")); + log_message(LOG_LEVEL_ERROR, "main: error, g_obj_wait failed"); break; } } /* cleanup */ main_cleanup(); - LOG(1, ("main: app exiting pid %d(0x%8.8x)", pid, pid)); + log_message(LOG_LEVEL_INFO, "main: app exiting pid %d(0x%8.8x)", pid, pid); g_deinit(); return 0; } diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index cf601a8e..0afff037 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -29,6 +29,7 @@ #include "parse.h" #include "os_calls.h" #include "chansrv.h" +#include "log.h" static Atom g_clipboard_atom = 0; static Atom g_clip_property_atom = 0; @@ -78,7 +79,7 @@ clipboard_error_handler(Display* dis, XErrorEvent* xer) char text[256]; XGetErrorText(dis, xer->error_code, text, 255); - LOG(1, ("error [%s]", text)); + log_message(LOG_LEVEL_ERROR,"error [%s]", text); return 0; } @@ -89,7 +90,7 @@ clipboard_error_handler(Display* dis, XErrorEvent* xer) int DEFAULT_CC clipboard_fatal_handler(Display* dis) { - LOG(1, ("fatal error, exiting")); + log_message(LOG_LEVEL_ALWAYS,"fatal error, exiting"); main_cleanup(); return 0; } @@ -137,7 +138,7 @@ clipboard_init(void) int ver_min; Status st; - LOG(5, ("xrdp-chansrv: in clipboard_init")); + log_message(LOG_LEVEL_DEBUG,"xrdp-chansrv: in clipboard_init"); if (g_clip_up) { return 0; @@ -151,7 +152,7 @@ clipboard_init(void) g_display = XOpenDisplay(0); if (g_display == 0) { - LOG(0, ("clipboard_init: XOpenDisplay failed")); + log_message(LOG_LEVEL_ERROR,"clipboard_init: XOpenDisplay failed"); rv = 1; } if (rv == 0) @@ -159,7 +160,7 @@ clipboard_init(void) g_x_socket = XConnectionNumber(g_display); if (g_x_socket == 0) { - LOG(0, ("clipboard_init: XConnectionNumber failed")); + log_message(LOG_LEVEL_ERROR,"clipboard_init: XConnectionNumber failed"); rv = 2; } g_x_wait_obj = g_create_wait_obj_from_socket(g_x_socket, 0); @@ -169,7 +170,7 @@ clipboard_init(void) g_clipboard_atom = XInternAtom(g_display, "CLIPBOARD", False); if (g_clipboard_atom == None) { - LOG(0, ("clipboard_init: XInternAtom failed")); + log_message(LOG_LEVEL_ERROR,"clipboard_init: XInternAtom failed"); rv = 3; } } @@ -177,15 +178,15 @@ clipboard_init(void) { if (!XFixesQueryExtension(g_display, &g_xfixes_event_base, &dummy)) { - LOG(0, ("clipboard_init: no xfixes")); + log_message(LOG_LEVEL_ERROR,"clipboard_init: no xfixes"); rv = 5; } } if (rv == 0) { - LOG(0, ("clipboard_init: g_xfixes_event_base %d", g_xfixes_event_base)); + log_message(LOG_LEVEL_ERROR,"clipboard_init: g_xfixes_event_base %d", g_xfixes_event_base); st = XFixesQueryVersion(g_display, &ver_maj, &ver_min); - LOG(0, ("clipboard_init st %d, maj %d min %d", st, ver_maj, ver_min)); + log_message(LOG_LEVEL_ERROR,"clipboard_init st %d, maj %d min %d", st, ver_maj, ver_min); g_screen_num = DefaultScreen(g_display); g_screen = ScreenOfDisplay(g_display, g_screen_num); g_clip_property_atom = XInternAtom(g_display, "XRDP_CLIP_PROPERTY_ATOM", @@ -219,13 +220,13 @@ clipboard_init(void) out_uint32_le(s, 0); /* extra 4 bytes ? */ s_mark_end(s); size = (int)(s->end - s->data); - LOG(5, ("clipboard_init: data out, sending " - "CLIPRDR_CONNECT (clip_msg_id = 1)")); + log_message(LOG_LEVEL_DEBUG,"clipboard_init: data out, sending " + "CLIPRDR_CONNECT (clip_msg_id = 1)"); rv = send_channel_data(g_cliprdr_chan_id, s->data, size); if (rv != 0) { - LOG(0, ("clipboard_init: send_channel_data failed " - "rv = %d", rv)); + log_message(LOG_LEVEL_ERROR,"clipboard_init: send_channel_data failed " + "rv = %d", rv); rv = 4; } free_stream(s); @@ -238,7 +239,7 @@ clipboard_init(void) } else { - LOG(0, ("xrdp-chansrv: clipboard_init: error on exit")); + log_message(LOG_LEVEL_ERROR,"xrdp-chansrv: clipboard_init: error on exit"); } return rv; } @@ -281,10 +282,10 @@ clipboard_send_data_request(void) int rv; int num_chars; - LOG(5, ("clipboard_send_data_request:")); + log_message(LOG_LEVEL_DEBUG,"clipboard_send_data_request:"); if (!g_got_format_announce) { - LOG(0, ("clipboard_send_data_request: error, no format announce")); + log_message(LOG_LEVEL_ERROR,"clipboard_send_data_request: error, no format announce"); return 0; } g_got_format_announce = 0; @@ -296,8 +297,8 @@ clipboard_send_data_request(void) out_uint32_le(s, 0x0d); s_mark_end(s); size = (int)(s->end - s->data); - LOG(5, ("clipboard_send_data_request: data out, sending " - "CLIPRDR_DATA_REQUEST (clip_msg_id = 4)")); + log_message(LOG_LEVEL_DEBUG,"clipboard_send_data_request: data out, sending " + "CLIPRDR_DATA_REQUEST (clip_msg_id = 4)"); rv = send_channel_data(g_cliprdr_chan_id, s->data, size); free_stream(s); return rv; @@ -319,8 +320,8 @@ clipboard_send_format_ack(void) out_uint32_le(s, 0); /* extra 4 bytes ? */ s_mark_end(s); size = (int)(s->end - s->data); - LOG(5, ("clipboard_send_format_ack: data out, sending " - "CLIPRDR_FORMAT_ACK (clip_msg_id = 3)")); + log_message(LOG_LEVEL_DEBUG,"clipboard_send_format_ack: data out, sending " + "CLIPRDR_FORMAT_ACK (clip_msg_id = 3)"); rv = send_channel_data(g_cliprdr_chan_id, s->data, size); free_stream(s); return rv; @@ -343,8 +344,8 @@ clipboard_send_format_announce(void) out_uint8s(s, 0x90); s_mark_end(s); size = (int)(s->end - s->data); - LOG(5, ("clipboard_send_format_announce: data out, sending " - "CLIPRDR_FORMAT_ANNOUNCE (clip_msg_id = 2)")); + log_message(LOG_LEVEL_DEBUG,"clipboard_send_format_announce: data out, sending " + "CLIPRDR_FORMAT_ANNOUNCE (clip_msg_id = 2)"); rv = send_channel_data(g_cliprdr_chan_id, s->data, size); free_stream(s); return rv; @@ -398,7 +399,7 @@ clipboard_send_data_response(void) num_chars = g_mbstowcs(0, g_last_clip_data, 0); if (num_chars < 0) { - LOG(0, ("clipboard_send_data_response: bad string")); + log_message(LOG_LEVEL_ERROR,"clipboard_send_data_response: bad string"); num_chars = 0; } } @@ -412,16 +413,16 @@ clipboard_send_data_response(void) out_uint32_le(s, num_chars * 2 + 2); /* length */ if (clipboard_out_unicode(s, g_last_clip_data, num_chars) != num_chars * 2) { - LOG(0, ("clipboard_send_data_response: error " - "clipboard_out_unicode didn't write right number of bytes")); + log_message(LOG_LEVEL_ERROR,"clipboard_send_data_response: error " + "clipboard_out_unicode didn't write right number of bytes"); } out_uint16_le(s, 0); /* nil for string */ out_uint32_le(s, 0); s_mark_end(s); size = (int)(s->end - s->data); - LOG(5, ("clipboard_send_data_response: data out, sending " + log_message(LOG_LEVEL_DEBUG,"clipboard_send_data_response: data out, sending " "CLIPRDR_DATA_RESPONSE (clip_msg_id = 5) size %d num_chars %d", - size, num_chars)); + size, num_chars); rv = send_channel_data(g_cliprdr_chan_id, s->data, size); free_stream(s); return rv; @@ -493,14 +494,14 @@ clipboard_process_format_announce(struct stream* s, int clip_msg_status, { Window owner; - LOG(5, ("clipboard_process_format_announce: CLIPRDR_FORMAT_ANNOUNCE")); + log_message(LOG_LEVEL_DEBUG,"clipboard_process_format_announce: CLIPRDR_FORMAT_ANNOUNCE"); //g_hexdump(s->p, s->end - s->p); clipboard_send_format_ack(); g_got_format_announce = 1; g_data_in_up_to_date = 0; if (clipboard_set_selection_owner() != 0) { - LOG(0, ("clipboard_process_format_announce: XSetSelectionOwner failed")); + log_message(LOG_LEVEL_ERROR,"clipboard_process_format_announce: XSetSelectionOwner failed"); } return 0; } @@ -510,7 +511,7 @@ static int APP_CC clipboard_prcoess_format_ack(struct stream* s, int clip_msg_status, int clip_msg_len) { - LOG(5, ("clipboard_prcoess_format_ack: CLIPRDR_FORMAT_ACK")); + log_message(LOG_LEVEL_DEBUG,"clipboard_prcoess_format_ack: CLIPRDR_FORMAT_ACK"); //g_hexdump(s->p, s->end - s->p); return 0; } @@ -520,7 +521,7 @@ static int APP_CC clipboard_process_data_request(struct stream* s, int clip_msg_status, int clip_msg_len) { - LOG(5, ("clipboard_process_data_request: CLIPRDR_DATA_REQUEST")); + log_message(LOG_LEVEL_DEBUG,"clipboard_process_data_request: CLIPRDR_DATA_REQUEST"); //g_hexdump(s->p, s->end - s->p); clipboard_send_data_response(); return 0; @@ -540,7 +541,7 @@ clipboard_process_data_response(struct stream* s, int clip_msg_status, int wtext_size; int data_in_len; - LOG(5, ("clipboard_process_data_response: CLIPRDR_DATA_RESPONSE")); + log_message(LOG_LEVEL_DEBUG,"clipboard_process_data_response: CLIPRDR_DATA_RESPONSE"); g_waiting_for_data_response = 0; len = (int)(s->end - s->p); if (len < 1) @@ -591,8 +592,8 @@ clipboard_process_data_response(struct stream* s, int clip_msg_status, lxev = &(g_selection_request_event[index]); clipboard_provide_selection(lxev, lxev->target, 8, g_data_in, data_in_len); - LOG(5, ("clipboard_process_data_response: requestor %d data_in_len %d", - lxev->requestor, data_in_len)); + log_message(LOG_LEVEL_DEBUG,"clipboard_process_data_response: requestor %d data_in_len %d", + lxev->requestor, data_in_len); } } g_selection_request_event_count = 0; @@ -658,7 +659,7 @@ clipboard_data_in(struct stream* s, int chan_id, int chan_flags, int length, clip_msg_len); break; default: - LOG(0, ("clipboard_data_in: unknown clip_msg_id %d", clip_msg_id)); + log_message(LOG_LEVEL_ERROR,"clipboard_data_in: unknown clip_msg_id %d", clip_msg_id); break; } XFlush(g_display); @@ -686,13 +687,13 @@ clipboard_event_selection_owner_notify(XEvent* xevent) XFixesSelectionNotifyEvent* lxevent; lxevent = (XFixesSelectionNotifyEvent*)xevent; - LOG(5, ("clipboard_event_selection_owner_notify: " + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_owner_notify: " "window %d subtype %d owner %d g_wnd %d", - lxevent->window, lxevent->subtype, lxevent->owner, g_wnd)); + lxevent->window, lxevent->subtype, lxevent->owner, g_wnd); if (lxevent->owner == g_wnd) { - LOG(5, ("clipboard_event_selection_owner_notify: skipping, " - "onwer == g_wnd")); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_owner_notify: skipping, " + "onwer == g_wnd"); g_got_selection = 1; return 0; } @@ -812,7 +813,7 @@ clipboard_event_selection_notify(XEvent* xevent) int* atoms; Atom type; - LOG(5, ("clipboard_event_selection_notify:")); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_notify:"); convert_to_string = 0; convert_to_utf8 = 0; send_format_announce = 0; @@ -822,8 +823,8 @@ clipboard_event_selection_notify(XEvent* xevent) lxevent = (XSelectionEvent*)xevent; if (lxevent->property == None) { - LOG(0, ("clipboard_event_selection_notify: clip could " - "not be converted")); + log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: clip could " + "not be converted"); rv = 1; } if (rv == 0) @@ -833,8 +834,8 @@ clipboard_event_selection_notify(XEvent* xevent) &n_items, &data, &data_size); if (rv != 0) { - LOG(0, ("clipboard_event_selection_notify: " - "clipboard_get_window_property failed error %d", rv)); + log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: " + "clipboard_get_window_property failed error %d", rv); } XDeleteProperty(g_display, lxevent->requestor, lxevent->property); } @@ -850,8 +851,8 @@ clipboard_event_selection_notify(XEvent* xevent) for (index = 0; index < n_items; index++) { atom = atoms[index]; - LOG(5, ("clipboard_event_selection_notify: %d %s %d", atom, - XGetAtomName(g_display, atom), XA_STRING)); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: %d %s %d", atom, + XGetAtomName(g_display, atom), XA_STRING); if (atom == g_utf8_atom) { convert_to_utf8 = 1; @@ -864,15 +865,15 @@ clipboard_event_selection_notify(XEvent* xevent) } else { - LOG(0, ("clipboard_event_selection_notify: error, target is " + log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: error, target is " "'TARGETS' and type[%d] or fmt[%d] not right, should be " - "type[%d], fmt[%d]", type, fmt, XA_ATOM, 32)); + "type[%d], fmt[%d]", type, fmt, XA_ATOM, 32); } } else if (lxevent->target == g_utf8_atom) { - LOG(5, ("clipboard_event_selection_notify: UTF8_STRING data_size %d", - data_size)); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: UTF8_STRING data_size %d", + data_size); g_free(g_last_clip_data); g_last_clip_size = data_size; g_last_clip_data = g_malloc(g_last_clip_size + 1, 0); @@ -883,8 +884,8 @@ clipboard_event_selection_notify(XEvent* xevent) } else if (lxevent->target == XA_STRING) { - LOG(5, ("clipboard_event_selection_notify: XA_STRING data_size %d", - data_size)); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_notify: XA_STRING data_size %d", + data_size); g_free(g_last_clip_data); g_last_clip_size = data_size; g_last_clip_data = g_malloc(g_last_clip_size + 1, 0); @@ -895,12 +896,12 @@ clipboard_event_selection_notify(XEvent* xevent) } else { - LOG(0, ("clipboard_event_selection_notify: unknown target")); + log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: unknown target"); } } else { - LOG(0, ("clipboard_event_selection_notify: unknown selection")); + log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_notify: unknown selection"); } } if (convert_to_utf8) @@ -952,19 +953,19 @@ clipboard_event_selection_request(XEvent* xevent) char* xdata; lxev = (XSelectionRequestEvent*)xevent; - LOG(5, ("clipboard_event_selection_request: g_wnd %d, " + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_wnd %d, " ".requestor %d .owner %d .selection %d '%s' .target %d .property %d", g_wnd, lxev->requestor, lxev->owner, lxev->selection, XGetAtomName(g_display, lxev->selection), - lxev->target, lxev->property)); + lxev->target, lxev->property); if (lxev->property == None) { - LOG(5, ("clipboard_event_selection_request: lxev->property is None")); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: lxev->property is None"); } else if (lxev->target == g_targets_atom) { /* requestor is asking what the selection can be converted to */ - LOG(5, ("clipboard_event_selection_request: g_targets_atom")); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_targets_atom"); ui32[0] = g_targets_atom; ui32[1] = g_timestamp_atom; ui32[2] = g_multiple_atom; @@ -975,29 +976,29 @@ clipboard_event_selection_request(XEvent* xevent) else if (lxev->target == g_timestamp_atom) { /* requestor is asking the time I got the selection */ - LOG(5, ("clipboard_event_selection_request: g_timestamp_atom")); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_timestamp_atom"); ui32[0] = g_selection_time; return clipboard_provide_selection(lxev, XA_INTEGER, 32, (char*)ui32, 1); } else if (lxev->target == g_multiple_atom) { /* target, property pairs */ - LOG(5, ("clipboard_event_selection_request: g_multiple_atom")); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_multiple_atom"); if (clipboard_get_window_property(xev.xselection.requestor, xev.xselection.property, &type, &fmt, &n_items, &xdata, &xdata_size) == 0) { - LOG(5, ("clipboard_event_selection_request: g_multiple_atom " - "n_items %d", n_items)); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: g_multiple_atom " + "n_items %d", n_items); /* todo */ g_free(xdata); } } else if ((lxev->target == XA_STRING) || (lxev->target == g_utf8_atom)) { - LOG(5, ("clipboard_event_selection_request: %s", - XGetAtomName(g_display, lxev->target))); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_request: %s", + XGetAtomName(g_display, lxev->target)); if (g_data_in_up_to_date) { return clipboard_provide_selection(lxev, lxev->target, 8, @@ -1005,7 +1006,7 @@ clipboard_event_selection_request(XEvent* xevent) } if (g_selection_request_event_count > 10) { - LOG(0, ("clipboard_event_selection_request: error, too many requests")); + log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_request: error, too many requests"); } else { @@ -1023,8 +1024,8 @@ clipboard_event_selection_request(XEvent* xevent) } else { - LOG(0, ("clipboard_event_selection_request: unknown " - "target %s", XGetAtomName(g_display, lxev->target))); + log_message(LOG_LEVEL_ERROR,"clipboard_event_selection_request: unknown " + "target %s", XGetAtomName(g_display, lxev->target)); } clipboard_refuse_selection(lxev); return 0; @@ -1045,7 +1046,7 @@ clipboard_event_selection_request(XEvent* xevent) static int APP_CC clipboard_event_selection_clear(XEvent* xevent) { - LOG(5, ("clipboard_event_selection_clear:")); + log_message(LOG_LEVEL_DEBUG,"clipboard_event_selection_clear:"); return 0; } @@ -1106,7 +1107,7 @@ clipboard_check_wait_objs(void) if (XPending(g_display) < 1) { /* something is wrong, should not get here */ - LOG(0, ("clipboard_check_wait_objs: sck closed")); + log_message(LOG_LEVEL_ERROR,"clipboard_check_wait_objs: sck closed"); return 0; } if (g_waiting_for_data_response) @@ -1115,8 +1116,8 @@ clipboard_check_wait_objs(void) g_waiting_for_data_response_time; if (time_diff > 1000) { - LOG(0, ("clipboard_check_wait_objs: warning, waiting for " - "data response too long")); + log_message(LOG_LEVEL_ERROR,"clipboard_check_wait_objs: warning, waiting for " + "data response too long"); } } while (XPending(g_display) > 0) @@ -1145,8 +1146,8 @@ clipboard_check_wait_objs(void) clipboard_event_selection_owner_notify(&xevent); break; } - LOG(0, ("clipboard_check_wait_objs unknown type %d", - xevent.type)); + log_message(LOG_LEVEL_ERROR,"clipboard_check_wait_objs unknown type %d", + xevent.type); break; } } diff --git a/sesman/config.c b/sesman/config.c index d81f7968..a4342676 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -29,28 +29,11 @@ #include "list.h" #include "file.h" #include "sesman.h" +#include "log.h" extern struct config_sesman* g_cfg; /* in sesman.c */ -/******************************************************************************/ -/** - * - * @brief Reads sesman configuration - * @param s translates the strings "1", "true" and "yes" in 1 (true) and other strings in 0 - * @return 0 on success, 1 on failure - * - */ -static int APP_CC -text2bool(char* s) -{ - if (0 == g_strcasecmp(s, "1") || - 0 == g_strcasecmp(s, "true") || - 0 == g_strcasecmp(s, "yes")) - { - return 1; - } - return 0; -} + /******************************************************************************/ int DEFAULT_CC @@ -66,16 +49,16 @@ config_read(struct config_sesman* cfg) fd = g_file_open(cfg_file); if (-1 == fd) { - if (g_cfg->log.fd >= 0) - { + //if (g_cfg->log.fd >= 0) + //{ /* logging is already active */ - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "error opening %s in \ + log_message(LOG_LEVEL_ALWAYS, "error opening %s in \ config_read", cfg_file); - } - else - { + //} + //else + //{ g_printf("error opening %s in config_read", cfg_file); - } + //} return 1; } g_memset(cfg, 0, sizeof(struct config_sesman)); @@ -95,7 +78,7 @@ config_read(struct config_sesman* cfg) config_read_rdp_params(fd, cfg, param_n, param_v); /* read logging config */ - config_read_logging(fd, &(cfg->log), param_n, param_v); + // config_read_logging(fd, &(cfg->log), param_n, param_v); /* read security config */ config_read_security(fd, &(cfg->sec), param_n, param_v); @@ -190,7 +173,7 @@ config_read_globals(int file, struct config_sesman* cf, struct list* param_n, return 0; } -/******************************************************************************/ +/****************************************************************************** int DEFAULT_CC config_read_logging(int file, struct log_config* lc, struct list* param_n, struct list* param_v) @@ -201,7 +184,7 @@ config_read_logging(int file, struct log_config* lc, struct list* param_n, list_clear(param_v); list_clear(param_n); - /* setting defaults */ + // setting defaults lc->program_name = g_strdup("sesman"); lc->log_file = 0; lc->fd = 0; @@ -244,7 +227,7 @@ config_read_logging(int file, struct log_config* lc, struct list* param_n, return 0; } - +*/ /******************************************************************************/ int DEFAULT_CC config_read_security(int file, struct config_security* sc, diff --git a/sesman/config.h b/sesman/config.h index 2a4ebd28..73fab38f 100644 --- a/sesman/config.h +++ b/sesman/config.h @@ -45,12 +45,13 @@ #define SESMAN_CFG_RDP_PARAMS "X11rdp" #define SESMAN_CFG_VNC_PARAMS "Xvnc" +/* #define SESMAN_CFG_LOGGING "Logging" #define SESMAN_CFG_LOG_FILE "LogFile" #define SESMAN_CFG_LOG_LEVEL "LogLevel" #define SESMAN_CFG_LOG_ENABLE_SYSLOG "EnableSyslog" #define SESMAN_CFG_LOG_SYSLOG_LEVEL "SyslogLevel" - +*/ #define SESMAN_CFG_SECURITY "Security" #define SESMAN_CFG_SEC_LOGIN_RETRY "MaxLoginRetry" #define SESMAN_CFG_SEC_ALLOW_ROOT "AllowRootLogin" @@ -186,7 +187,7 @@ struct config_sesman * @var log * @brief Log configuration struct */ - struct log_config log; + //struct log_config log; /** * @var sec * @brief Security configuration options struct diff --git a/sesman/env.c b/sesman/env.c index 4bcb22e8..f7abe120 100644 --- a/sesman/env.c +++ b/sesman/env.c @@ -47,7 +47,7 @@ env_check_password_file(char* filename, char* password) fd = g_file_open(filename); if (fd == -1) { - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, + log_message(LOG_LEVEL_WARNING, "can't read vnc password file - %s", filename); return 1; @@ -112,13 +112,13 @@ env_set_user(char* username, char* passwd_file, int display) /* we use auth_file_path as requested */ g_sprintf(passwd_file, g_cfg->auth_file_path, username); } - LOG_DBG(&(g_cfg->log), "pass file: %s", passwd_file); + LOG_DBG("pass file: %s", passwd_file); } } } else { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, + log_message(LOG_LEVEL_ERROR, "error getting user info for user %s", username); } return error; diff --git a/sesman/libscp/libscp_connection.c b/sesman/libscp/libscp_connection.c index 0b09852e..bf49fb84 100644 --- a/sesman/libscp/libscp_connection.c +++ b/sesman/libscp/libscp_connection.c @@ -27,7 +27,7 @@ #include "libscp_connection.h" -extern struct log_config* s_log; +//extern struct log_config* s_log; struct SCP_CONNECTION* scp_connection_create(int sck) @@ -38,7 +38,7 @@ scp_connection_create(int sck) if (0 == conn) { - log_message(s_log, LOG_LEVEL_WARNING, "[connection:%d] connection create: malloc error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[connection:%d] connection create: malloc error", __LINE__); return 0; } diff --git a/sesman/libscp/libscp_init.c b/sesman/libscp/libscp_init.c index 22497ac2..4c48fb1f 100644 --- a/sesman/libscp/libscp_init.c +++ b/sesman/libscp/libscp_init.c @@ -27,22 +27,24 @@ #include "libscp_init.h" -struct log_config* s_log; +//struct log_config* s_log; /* server API */ int DEFAULT_CC -scp_init(struct log_config* log) +scp_init() { +/* if (0 == log) { return 1; } +*/ - s_log = log; + //s_log = log; scp_lock_init(); - log_message(s_log, LOG_LEVEL_WARNING, "[init:%d] libscp initialized", __LINE__); + log_message(LOG_LEVEL_WARNING, "[init:%d] libscp initialized", __LINE__); return 0; } diff --git a/sesman/libscp/libscp_init.h b/sesman/libscp/libscp_init.h index 5ac0ba02..92dbc659 100644 --- a/sesman/libscp/libscp_init.h +++ b/sesman/libscp/libscp_init.h @@ -42,7 +42,7 @@ * */ int DEFAULT_CC -scp_init(struct log_config* log); +scp_init(); #endif diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c index 8ac94d25..244f188a 100644 --- a/sesman/libscp/libscp_session.c +++ b/sesman/libscp/libscp_session.c @@ -31,7 +31,7 @@ #include <sys/socket.h> #include <arpa/inet.h> -extern struct log_config* s_log; +//extern struct log_config* s_log; /*******************************************************************/ struct SCP_SESSION* @@ -42,7 +42,7 @@ scp_session_create() s = (struct SCP_SESSION*)g_malloc(sizeof(struct SCP_SESSION), 1); if (0 == s) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] session create: malloc error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] session create: malloc error", __LINE__); return 0; } return s; @@ -65,12 +65,12 @@ scp_session_set_type(struct SCP_SESSION* s, tui8 type) s->mng = (struct SCP_MNG_DATA*)g_malloc(sizeof(struct SCP_MNG_DATA), 1); if (NULL == s->mng) { - log_message(s_log, LOG_LEVEL_ERROR, "[session:%d] set_type: internal error", __LINE__); + log_message(LOG_LEVEL_ERROR, "[session:%d] set_type: internal error", __LINE__); return 1; } break; default: - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_type: unknown type", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_type: unknown type", __LINE__); return 1; } return 0; @@ -89,7 +89,7 @@ scp_session_set_version(struct SCP_SESSION* s, tui32 version) s->version = 1; break; default: - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_version: unknown version", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_version: unknown version", __LINE__); return 1; } return 0; @@ -149,7 +149,7 @@ scp_session_set_locale(struct SCP_SESSION* s, char* str) { if (0 == str) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_locale: null locale", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_locale: null locale", __LINE__); s->locale[0]='\0'; return 1; } @@ -164,7 +164,7 @@ scp_session_set_username(struct SCP_SESSION* s, char* str) { if (0 == str) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_username: null username", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_username: null username", __LINE__); return 1; } if (0 != s->username) @@ -174,7 +174,7 @@ scp_session_set_username(struct SCP_SESSION* s, char* str) s->username = g_strdup(str); if (0 == s->username) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_username: strdup error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_username: strdup error", __LINE__); return 1; } return 0; @@ -186,7 +186,7 @@ scp_session_set_password(struct SCP_SESSION* s, char* str) { if (0 == str) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_password: null password", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_password: null password", __LINE__); return 1; } if (0 != s->password) @@ -196,7 +196,7 @@ scp_session_set_password(struct SCP_SESSION* s, char* str) s->password = g_strdup(str); if (0 == s->password) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_password: strdup error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_password: strdup error", __LINE__); return 1; } return 0; @@ -208,7 +208,7 @@ scp_session_set_domain(struct SCP_SESSION* s, char* str) { if (0 == str) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_domain: null domain", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_domain: null domain", __LINE__); return 1; } if (0 != s->domain) @@ -218,7 +218,7 @@ scp_session_set_domain(struct SCP_SESSION* s, char* str) s->domain = g_strdup(str); if (0 == s->domain) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_domain: strdup error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_domain: strdup error", __LINE__); return 1; } return 0; @@ -230,7 +230,7 @@ scp_session_set_program(struct SCP_SESSION* s, char* str) { if (0 == str) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_program: null program", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_program: null program", __LINE__); return 1; } if (0 != s->program) @@ -240,7 +240,7 @@ scp_session_set_program(struct SCP_SESSION* s, char* str) s->program = g_strdup(str); if (0 == s->program) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_program: strdup error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_program: strdup error", __LINE__); return 1; } return 0; @@ -252,7 +252,7 @@ scp_session_set_directory(struct SCP_SESSION* s, char* str) { if (0 == str) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_directory: null directory", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_directory: null directory", __LINE__); return 1; } if (0 != s->directory) @@ -262,7 +262,7 @@ scp_session_set_directory(struct SCP_SESSION* s, char* str) s->directory = g_strdup(str); if (0 == s->directory) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_directory: strdup error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_directory: strdup error", __LINE__); return 1; } return 0; @@ -274,7 +274,7 @@ scp_session_set_client_ip(struct SCP_SESSION* s, char* str) { if (0 == str) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_client_ip: null ip", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: null ip", __LINE__); return 1; } if (0 != s->client_ip) @@ -284,7 +284,7 @@ scp_session_set_client_ip(struct SCP_SESSION* s, char* str) s->client_ip = g_strdup(str); if (0 == s->client_ip) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_client_ip: strdup error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_client_ip: strdup error", __LINE__); return 1; } return 0; @@ -296,7 +296,7 @@ scp_session_set_hostname(struct SCP_SESSION* s, char* str) { if (0 == str) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_hostname: null hostname", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_hostname: null hostname", __LINE__); return 1; } if (0 != s->hostname) @@ -306,7 +306,7 @@ scp_session_set_hostname(struct SCP_SESSION* s, char* str) s->hostname = g_strdup(str); if (0 == s->hostname) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_hostname: strdup error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_hostname: strdup error", __LINE__); return 1; } return 0; @@ -318,7 +318,7 @@ scp_session_set_errstr(struct SCP_SESSION* s, char* str) { if (0 == str) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_errstr: null string", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_errstr: null string", __LINE__); return 1; } if (0 != s->errstr) @@ -328,7 +328,7 @@ scp_session_set_errstr(struct SCP_SESSION* s, char* str) s->errstr = g_strdup(str); if (0 == s->errstr) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_errstr: strdup error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_errstr: strdup error", __LINE__); return 1; } return 0; @@ -359,7 +359,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr) ret = inet_pton(AF_INET, addr, &ip4); if (ret == 0) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__); inet_pton(AF_INET, "127.0.0.1", &ip4); g_memcpy(&(s->ipv4addr), &(ip4.s_addr), 4); return 1; @@ -375,7 +375,7 @@ scp_session_set_addr(struct SCP_SESSION* s, int type, void* addr) ret = inet_pton(AF_INET6, addr, &ip6); if (ret == 0) { - log_message(s_log, LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__); + log_message(LOG_LEVEL_WARNING, "[session:%d] set_addr: invalid address", __LINE__); inet_pton(AF_INET, "::1", &ip6); g_memcpy(s->ipv6addr, &(ip6.s6_addr), 16); return 1; diff --git a/sesman/libscp/libscp_tcp.c b/sesman/libscp/libscp_tcp.c index 6ffa4693..459992fe 100644 --- a/sesman/libscp/libscp_tcp.c +++ b/sesman/libscp/libscp_tcp.c @@ -42,7 +42,7 @@ scp_tcp_force_recv(int sck, char* data, int len) int rcvd; int block; - LOG_DBG(s_log, "scp_tcp_force_recv()"); + LOG_DBG("scp_tcp_force_recv()"); block = scp_lock_fork_critical_section_start(); while (len > 0) @@ -84,7 +84,7 @@ scp_tcp_force_send(int sck, char* data, int len) int sent; int block; - LOG_DBG(s_log, "scp_tcp_force_send()"); + LOG_DBG("scp_tcp_force_send()"); block = scp_lock_fork_critical_section_start(); while (len > 0) diff --git a/sesman/libscp/libscp_v0.c b/sesman/libscp/libscp_v0.c index d46d6afa..69dd4afa 100644 --- a/sesman/libscp/libscp_v0.c +++ b/sesman/libscp/libscp_v0.c @@ -43,7 +43,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s) init_stream(c->in_s, c->in_s->size); init_stream(c->out_s, c->in_s->size); - LOG_DBG(s_log, "[v0:%d] starting connection", __LINE__); + LOG_DBG("[v0:%d] starting connection", __LINE__); g_tcp_set_non_blocking(c->in_sck); g_tcp_set_no_delay(c->in_sck); s_push_layer(c->out_s, channel_hdr, 8); @@ -59,7 +59,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s) } else { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_INTERNAL_ERR; } sz = g_strlen(s->username); @@ -83,27 +83,27 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s) if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_NETWORK_ERR; } if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_NETWORK_ERR; } in_uint32_be(c->in_s, version); if (0 != version) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__); return SCP_CLIENT_STATE_VERSION_ERR; } in_uint32_be(c->in_s, size); if (size < 14) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: packet size error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: packet size error", __LINE__); return SCP_CLIENT_STATE_SIZE_ERR; } @@ -111,7 +111,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s) init_stream(c->in_s, c->in_s->size); if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_NETWORK_ERR; } @@ -119,7 +119,7 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s) in_uint16_be(c->in_s, sz); if (3 != sz) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__); return SCP_CLIENT_STATE_SEQUENCE_ERR; } @@ -127,14 +127,14 @@ scp_v0c_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s) in_uint16_be(c->in_s, sz); if (1 != sz) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: connection denied", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: connection denied", __LINE__); return SCP_CLIENT_STATE_CONNECTION_DENIED; } in_uint16_be(c->in_s, sz); s->display = sz; - LOG_DBG(s_log, "[v0:%d] connection terminated", __LINE__); + LOG_DBG("[v0:%d] connection terminated", __LINE__); return SCP_CLIENT_STATE_END; } @@ -152,20 +152,20 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk) if (!skipVchk) { - LOG_DBG(s_log, "[v0:%d] starting connection", __LINE__); + LOG_DBG("[v0:%d] starting connection", __LINE__); if (0 == scp_tcp_force_recv(c->in_sck, c->in_s->data, 8)) { c->in_s->end = c->in_s->data + 8; in_uint32_be(c->in_s, version); if (version != 0) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: version error", __LINE__); return SCP_SERVER_STATE_VERSION_ERR; } } else { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } } @@ -175,7 +175,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk) init_stream(c->in_s, 8196); if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } c->in_s->end = c->in_s->data + (size - 8); @@ -187,7 +187,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk) session = scp_session_create(); if (0 == session) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } @@ -208,7 +208,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk) if (0 != scp_session_set_username(session, buf)) { scp_session_destroy(session); - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting username", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting username", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } @@ -219,7 +219,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk) if (0 != scp_session_set_password(session, buf)) { scp_session_destroy(session); - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting password", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: error setting password", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } @@ -279,7 +279,7 @@ scp_v0s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk) } else { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } @@ -300,11 +300,11 @@ scp_v0s_allow_connection(struct SCP_CONNECTION* c, SCP_DISPLAY d) if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } - LOG_DBG(s_log, "[v0:%d] connection terminated (allowed)", __LINE__); + LOG_DBG("[v0:%d] connection terminated (allowed)", __LINE__); return SCP_SERVER_STATE_OK; } @@ -321,10 +321,10 @@ scp_v0s_deny_connection(struct SCP_CONNECTION* c) if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, c->out_s->end - c->out_s->data)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } - LOG_DBG(s_log, "[v0:%d] connection terminated (denied)", __LINE__); + LOG_DBG("[v0:%d] connection terminated (denied)", __LINE__); return SCP_SERVER_STATE_OK; } diff --git a/sesman/libscp/libscp_v1c_mng.c b/sesman/libscp/libscp_v1c_mng.c index bb54bc79..88f86f4f 100644 --- a/sesman/libscp/libscp_v1c_mng.c +++ b/sesman/libscp/libscp_v1c_mng.c @@ -30,7 +30,7 @@ #include <stdlib.h> #include <stdio.h> -extern struct log_config* s_log; +//extern struct log_config* s_log; static enum SCP_CLIENT_STATES_E _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s); @@ -91,7 +91,7 @@ scp_v1c_mng_connect(struct SCP_CONNECTION* c, struct SCP_SESSION* s) if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, size)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_NETWORK_ERR; } @@ -127,7 +127,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount, if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, size)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_NETWORK_ERR; } @@ -137,42 +137,42 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount, init_stream(c->in_s, c->in_s->size); if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_NETWORK_ERR; } in_uint32_be(c->in_s, version); if (version != 1) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__); return SCP_CLIENT_STATE_VERSION_ERR; } in_uint32_be(c->in_s, size); if (size < 12) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: size error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: size error", __LINE__); return SCP_CLIENT_STATE_SIZE_ERR; } init_stream(c->in_s, c->in_s->size); if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_NETWORK_ERR; } in_uint16_be(c->in_s, cmd); if (cmd != SCP_COMMAND_SET_MANAGE) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__); return SCP_CLIENT_STATE_SEQUENCE_ERR; } in_uint16_be(c->in_s, cmd); if (cmd != SCP_CMD_MNG_LIST) /* session list */ { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__); return SCP_CLIENT_STATE_SEQUENCE_ERR; } @@ -188,14 +188,14 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount, (*scount) = sescnt; (*s) = NULL; - LOG_DBG(s_log, "[v1c_mng] end list - no session on TS"); + LOG_DBG("[v1c_mng] end list - no session on TS"); return SCP_CLIENT_STATE_LIST_OK; } ds = g_malloc(sizeof(struct SCP_DISCONNECTED_SESSION) * sescnt, 0); if (ds == 0) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: internal error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: internal error", __LINE__); return SCP_CLIENT_STATE_INTERNAL_ERR; } } @@ -240,7 +240,7 @@ scp_v1c_mng_get_session_list(struct SCP_CONNECTION* c, int* scount, (*scount) = sescnt; (*s) = ds; - LOG_DBG(s_log, "[v1c_mng] end list"); + LOG_DBG("[v1c_mng] end list"); return SCP_CLIENT_STATE_LIST_OK; } @@ -350,14 +350,14 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s) init_stream(c->in_s, c->in_s->size); if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_NETWORK_ERR; } in_uint32_be(c->in_s, version); if (version != 1) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: version error", __LINE__); return SCP_CLIENT_STATE_VERSION_ERR; } @@ -367,21 +367,21 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s) /* read the rest of the packet */ if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: network error", __LINE__); return SCP_CLIENT_STATE_NETWORK_ERR; } in_uint16_be(c->in_s, cmd); if (cmd != SCP_COMMAND_SET_MANAGE) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c_mng:%d] connection aborted: sequence error", __LINE__); return SCP_CLIENT_STATE_SEQUENCE_ERR; } in_uint16_be(c->in_s, cmd); if (cmd == SCP_CMD_MNG_LOGIN_ALLOW) /* connection ok */ { - log_message(s_log, LOG_LEVEL_INFO, "[v1c_mng:%d] connection ok", __LINE__); + log_message(LOG_LEVEL_INFO, "[v1c_mng:%d] connection ok", __LINE__); return SCP_CLIENT_STATE_OK; } else if (cmd == SCP_CMD_MNG_LOGIN_DENY) /* connection denied */ @@ -391,10 +391,10 @@ _scp_v1c_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s) in_uint8a(c->in_s, buf, dim); scp_session_set_errstr(s, buf); - log_message(s_log, LOG_LEVEL_INFO, "[v1c_mng:%d] connection denied: %s", __LINE__ , s->errstr); + log_message(LOG_LEVEL_INFO, "[v1c_mng:%d] connection denied: %s", __LINE__ , s->errstr); return SCP_CLIENT_STATE_CONNECTION_DENIED; } - log_message(s_log, LOG_LEVEL_WARNING, "[v1c-mng:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1c-mng:%d] connection aborted: sequence error", __LINE__); return SCP_CLIENT_STATE_SEQUENCE_ERR; } diff --git a/sesman/libscp/libscp_v1s.c b/sesman/libscp/libscp_v1s.c index e57a907e..6b54a14b 100644 --- a/sesman/libscp/libscp_v1s.c +++ b/sesman/libscp/libscp_v1s.c @@ -30,7 +30,7 @@ #include "libscp_v1s.h" -extern struct log_config* s_log; +//extern struct log_config* s_log; /* server API */ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SESSION** s, int skipVchk) @@ -51,13 +51,13 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES in_uint32_be(c->in_s, version); if (version != 1) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__); return SCP_SERVER_STATE_VERSION_ERR; } } else { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } } @@ -65,14 +65,14 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES in_uint32_be(c->in_s, size); if (size < 12) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__); return SCP_SERVER_STATE_SIZE_ERR; } init_stream(c->in_s, c->in_s->size); if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8))) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } @@ -82,7 +82,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES /* if we are starting a management session */ if (cmdset == SCP_COMMAND_SET_MANAGE) { - log_message(s_log, LOG_LEVEL_DEBUG, "[v1s:%d] requested management connection", __LINE__); + log_message(LOG_LEVEL_DEBUG, "[v1s:%d] requested management connection", __LINE__); /* should return SCP_SERVER_STATE_START_MANAGE */ return scp_v1s_mng_accept(c, s); } @@ -90,7 +90,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES /* if we started with resource sharing... */ if (cmdset == SCP_COMMAND_SET_RSR) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } @@ -98,14 +98,14 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES in_uint16_be(c->in_s, cmd); if (cmd != 1) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } session = scp_session_create(); if (0 == session) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (malloc returned NULL)", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (malloc returned NULL)", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } scp_session_set_version(session, 1); @@ -114,7 +114,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES if ((sz != SCP_SESSION_TYPE_XVNC) && (sz != SCP_SESSION_TYPE_XRDP)) { scp_session_destroy(session); - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: unknown session type", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: unknown session type", __LINE__); return SCP_SERVER_STATE_SESSION_TYPE_ERR; } scp_session_set_type(session, sz); @@ -151,7 +151,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES if (0 != scp_session_set_hostname(session, buf)) { scp_session_destroy(session); - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } @@ -162,7 +162,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES if (0 != scp_session_set_username(session, buf)) { scp_session_destroy(session); - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } @@ -173,7 +173,7 @@ enum SCP_SERVER_STATES_E scp_v1s_accept(struct SCP_CONNECTION* c, struct SCP_SES if (0 != scp_session_set_password(session, buf)) { scp_session_destroy(session); - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } @@ -208,7 +208,7 @@ scp_v1s_deny_connection(struct SCP_CONNECTION* c, char* reason) if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, rlen+14)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } @@ -250,49 +250,49 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char* if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, 14+rlen)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } /* receive password & username */ if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } in_uint32_be(c->in_s, version); if (version!=1) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__); return SCP_SERVER_STATE_VERSION_ERR; } in_uint32_be(c->in_s, size); if (size<12) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__); return SCP_SERVER_STATE_SIZE_ERR; } init_stream(c->in_s, c->in_s->size); if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8))) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } in_uint16_be(c->in_s, cmdset); if (cmdset != SCP_COMMAND_SET_DEFAULT) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } in_uint16_be(c->in_s, cmd); if (cmd != 4) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } @@ -304,7 +304,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char* if (0 != scp_session_set_username(s, buf)) { scp_session_destroy(s); - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } @@ -315,7 +315,7 @@ scp_v1s_request_password(struct SCP_CONNECTION* c, struct SCP_SESSION* s, char* if (0 != scp_session_set_password(s, buf)) { scp_session_destroy(s); - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error", __LINE__); return SCP_SERVER_STATE_INTERNAL_ERR; } @@ -356,7 +356,7 @@ scp_v1s_connect_new_session(struct SCP_CONNECTION* c, SCP_DISPLAY d) if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, 14)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } @@ -410,7 +410,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, size)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } @@ -420,42 +420,42 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC init_stream(c->in_s, c->in_s->size); if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } in_uint32_be(c->in_s, version); if (version!=1) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__); return SCP_SERVER_STATE_VERSION_ERR; } in_uint32_be(c->in_s, size); if (size<12) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__); return SCP_SERVER_STATE_SIZE_ERR; } init_stream(c->in_s, c->in_s->size); if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8))) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } in_uint16_be(c->in_s, cmd); if (cmd != SCP_COMMAND_SET_DEFAULT) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } in_uint16_be(c->in_s, cmd); if (cmd != 41) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } @@ -542,7 +542,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC if (0 != scp_tcp_force_send(c->in_sck, c->out_s->data, size)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } } @@ -551,21 +551,21 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC init_stream(c->in_s, c->in_s->size); if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (8))) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } in_uint32_be(c->in_s, version); if (version != 1) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: version error", __LINE__); return SCP_SERVER_STATE_VERSION_ERR; } in_uint32_be(c->in_s, size); if (size < 12) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: size error", __LINE__); return SCP_SERVER_STATE_SIZE_ERR; } @@ -573,14 +573,14 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC init_stream(c->in_s, c->in_s->size); if (0!=scp_tcp_force_recv(c->in_sck, c->in_s->data, (size-8))) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } in_uint16_be(c->in_s, cmd); if (cmd != SCP_COMMAND_SET_DEFAULT) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } @@ -603,7 +603,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC /* if we got here, the requested sid wasn't one from the list we sent */ /* we should kill the connection */ - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (no such session in list)", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: internal error (no such session in list)", __LINE__); return SCP_CLIENT_STATE_INTERNAL_ERR; } else if (cmd == 44) @@ -619,7 +619,7 @@ scp_v1s_list_sessions(struct SCP_CONNECTION* c, int sescnt, struct SCP_DISCONNEC else { /* wrong response */ - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } @@ -656,7 +656,7 @@ scp_v1s_reconnect_session(struct SCP_CONNECTION* c, SCP_DISPLAY d) if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, size)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } diff --git a/sesman/libscp/libscp_v1s_mng.c b/sesman/libscp/libscp_v1s_mng.c index 266c9962..599545ab 100644 --- a/sesman/libscp/libscp_v1s_mng.c +++ b/sesman/libscp/libscp_v1s_mng.c @@ -30,7 +30,7 @@ #include "libscp_v1s_mng.h" -extern struct log_config* s_log; +//extern struct log_config* s_log; static enum SCP_SERVER_STATES_E _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s); @@ -259,7 +259,7 @@ scp_v1s_mng_list_sessions(struct SCP_CONNECTION* c, struct SCP_SESSION* s, if (0!=scp_tcp_force_send(c->in_sck, c->out_s->data, size)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } } @@ -279,14 +279,14 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s) init_stream(c->in_s, c->in_s->size); if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } in_uint32_be(c->in_s, version); if (version != 1) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: version error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: version error", __LINE__); return SCP_SERVER_STATE_VERSION_ERR; } @@ -296,21 +296,21 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s) /* read the rest of the packet */ if (0 != scp_tcp_force_recv(c->in_sck, c->in_s->data, size - 8)) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: network error", __LINE__); return SCP_SERVER_STATE_NETWORK_ERR; } in_uint16_be(c->in_s, cmd); if (cmd != SCP_COMMAND_SET_MANAGE) { - log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } in_uint16_be(c->in_s, cmd); if (cmd == SCP_CMD_MNG_LIST_REQ) /* request session list */ { - log_message(s_log, LOG_LEVEL_INFO, "[v1s_mng:%d] request session list", __LINE__); + log_message(LOG_LEVEL_INFO, "[v1s_mng:%d] request session list", __LINE__); return SCP_SERVER_STATE_MNG_LISTREQ; } else if (cmd == SCP_CMD_MNG_ACTION) /* execute an action */ @@ -320,7 +320,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s) in_uint8a(c->in_s, buf, dim); scp_session_set_errstr(s, buf);*/ - log_message(s_log, LOG_LEVEL_INFO, "[v1s_mng:%d] action request", __LINE__); + log_message(LOG_LEVEL_INFO, "[v1s_mng:%d] action request", __LINE__); return SCP_SERVER_STATE_MNG_ACTION; } /* else if (cmd == 20) / * password change * / @@ -334,7 +334,7 @@ _scp_v1s_mng_check_response(struct SCP_CONNECTION* c, struct SCP_SESSION* s) return SCP_SERVER_STATE_SESSION_LIST; }*/ - log_message(s_log, LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__); + log_message(LOG_LEVEL_WARNING, "[v1s_mng:%d] connection aborted: sequence error", __LINE__); return SCP_SERVER_STATE_SEQUENCE_ERR; } diff --git a/sesman/lock.c b/sesman/lock.c index d5a91af6..83023cba 100644 --- a/sesman/lock.c +++ b/sesman/lock.c @@ -55,7 +55,7 @@ void APP_CC lock_chain_acquire(void) { /* lock the chain */ - LOG_DBG(&(g_cfg->log), "lock_chain_acquire()"); + LOG_DBG("lock_chain_acquire()"); tc_mutex_lock(g_lock_chain); } @@ -64,7 +64,7 @@ void APP_CC lock_chain_release(void) { /* unlock the chain */ - LOG_DBG(&(g_cfg->log), "lock_chain_release()"); + LOG_DBG("lock_chain_release()"); tc_mutex_unlock(g_lock_chain); } @@ -73,7 +73,7 @@ void APP_CC lock_socket_acquire(void) { /* lock socket variable */ - LOG_DBG(&(g_cfg->log), "lock_socket_acquire()"); + LOG_DBG("lock_socket_acquire()"); tc_sem_dec(g_lock_socket); } @@ -82,7 +82,7 @@ void APP_CC lock_socket_release(void) { /* unlock socket variable */ - LOG_DBG(&(g_cfg->log), "lock_socket_release()"); + LOG_DBG("lock_socket_release()"); tc_sem_inc(g_lock_socket); } @@ -91,7 +91,7 @@ void APP_CC lock_sync_acquire(void) { /* lock sync variable */ - LOG_DBG(&(g_cfg->log), "lock_sync_acquire()"); + LOG_DBG("lock_sync_acquire()"); tc_mutex_lock(g_sync_mutex); } @@ -100,7 +100,7 @@ void APP_CC lock_sync_release(void) { /* unlock socket variable */ - LOG_DBG(&(g_cfg->log), "lock_sync_release()"); + LOG_DBG("lock_sync_release()"); tc_mutex_unlock(g_sync_mutex); } @@ -109,7 +109,7 @@ void APP_CC lock_sync_sem_acquire(void) { /* dec sem */ - LOG_DBG(&(g_cfg->log), "lock_sync_sem_acquire()"); + LOG_DBG("lock_sync_sem_acquire()"); tc_sem_dec(g_sync_sem); } @@ -118,6 +118,6 @@ void APP_CC lock_sync_sem_release(void) { /* inc sem */ - LOG_DBG(&(g_cfg->log), "lock_sync_sem_release()"); + LOG_DBG("lock_sync_sem_release()"); tc_sem_inc(g_sync_sem); } diff --git a/sesman/scp.c b/sesman/scp.c index 439c046c..bbe495ea 100644 --- a/sesman/scp.c +++ b/sesman/scp.c @@ -43,7 +43,7 @@ scp_process_start(void* sck) /* making a local copy of the socket (it's on the stack) */ /* probably this is just paranoia */ scon.in_sck = g_thread_sck; - LOG_DBG(&(g_cfg->log), "started scp thread on socket %d", scon.in_sck); + LOG_DBG("started scp thread on socket %d", scon.in_sck); /* unlocking g_thread_sck */ lock_socket_release(); @@ -60,40 +60,40 @@ scp_process_start(void* sck) if (sdata->version == 0) { /* starts processing an scp v0 connection */ - LOG_DBG(&(g_cfg->log), "accept ok, go on with scp v0\n",0); + LOG_DBG("accept ok, go on with scp v0\n",0); scp_v0_process(&scon, sdata); } else { - LOG_DBG(&(g_cfg->log), "accept ok, go on with scp v1\n",0); - /*LOG_DBG(&(g_cfg->log), "user: %s\npass: %s",sdata->username, sdata->password);*/ + LOG_DBG("accept ok, go on with scp v1\n",0); + /*LOG_DBG("user: %s\npass: %s",sdata->username, sdata->password);*/ scp_v1_process(&scon, sdata); } break; case SCP_SERVER_STATE_START_MANAGE: /* starting a management session */ - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, + log_message(LOG_LEVEL_WARNING, "starting a sesman management session..."); scp_v1_mng_process(&scon, sdata); break; case SCP_SERVER_STATE_VERSION_ERR: /* an unknown scp version was requested, so we shut down the */ /* connection (and log the fact) */ - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, + log_message(LOG_LEVEL_WARNING, "unknown protocol version specified. connection refused."); break; case SCP_SERVER_STATE_NETWORK_ERR: - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp network error."); + log_message(LOG_LEVEL_WARNING, "libscp network error."); break; case SCP_SERVER_STATE_SEQUENCE_ERR: - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp sequence error."); + log_message(LOG_LEVEL_WARNING, "libscp sequence error."); break; case SCP_SERVER_STATE_INTERNAL_ERR: /* internal error occurred (eg. malloc() error, ecc.) */ - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "libscp internal error occurred."); + log_message(LOG_LEVEL_ERROR, "libscp internal error occurred."); break; default: - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "unknown return from scp_vXs_accept()"); + log_message(LOG_LEVEL_ALWAYS, "unknown return from scp_vXs_accept()"); } g_tcp_close(scon.in_sck); free_stream(scon.in_s); diff --git a/sesman/scp_v0.c b/sesman/scp_v0.c index 0b4dc791..e36aeaf6 100644 --- a/sesman/scp_v0.c +++ b/sesman/scp_v0.c @@ -47,39 +47,39 @@ scp_v0_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) display = s_item->display; if (0 != s->client_ip) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, s_item->pid, s->client_ip); + log_message( LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, s_item->pid, s->client_ip); } else { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d", s->username, display, s_item->pid); + log_message(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d", s->username, display, s_item->pid); } auth_end(data); /* don't set data to null here */ } else { - LOG_DBG(&(g_cfg->log), "pre auth"); + LOG_DBG("pre auth"); if (1 == access_login_allowed(s->username)) { if (0 != s->client_ip) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ created session (access granted): username %s, ip %s", s->username, s->client_ip); + log_message(LOG_LEVEL_INFO, "++ created session (access granted): username %s, ip %s", s->username, s->client_ip); } else { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ created session (access granted): username %s", s->username); + log_message(LOG_LEVEL_INFO, "++ created session (access granted): username %s", s->username); } if (SCP_SESSION_TYPE_XVNC == s->type) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting Xvnc session..."); + log_message( LOG_LEVEL_INFO, "starting Xvnc session..."); display = session_start(s->width, s->height, s->bpp, s->username, s->password, data, SESMAN_SESSION_TYPE_XVNC, s->domain, s->program, s->directory, s->client_ip); } else { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting X11rdp session..."); + log_message(LOG_LEVEL_INFO, "starting X11rdp session..."); display = session_start(s->width, s->height, s->bpp, s->username, s->password, data, SESMAN_SESSION_TYPE_XRDP, s->domain, s->program, s->directory, s->client_ip); diff --git a/sesman/scp_v1.c b/sesman/scp_v1.c index 5c303bb2..d1509224 100644 --- a/sesman/scp_v1.c +++ b/sesman/scp_v1.c @@ -56,7 +56,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) while ((!data) && ((retries == 0) || (current_try > 0))) { - LOG_DBG(&(g_cfg->log), "data %d - retry %d - currenttry %d - expr %d", data, retries, current_try, ((!data) && ((retries==0) || (current_try>0)))); + LOG_DBG("data %d - retry %d - currenttry %d - expr %d", data, retries, current_try, ((!data) && ((retries==0) || (current_try>0)))); e=scp_v1s_request_password(c,s,"Wrong username and/or password"); @@ -83,7 +83,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) if (!data) { scp_v1s_deny_connection(c, "Login failed"); - log_message(&(g_cfg->log), LOG_LEVEL_INFO, + log_message( LOG_LEVEL_INFO, "Login failed for user %s. Connection terminated", s->username); scp_session_destroy(s); return; @@ -93,7 +93,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) if (0 == access_login_allowed(s->username)) { scp_v1s_deny_connection(c, "Access to Terminal Server not allowed."); - log_message(&(g_cfg->log), LOG_LEVEL_INFO, + log_message(LOG_LEVEL_INFO, "User %s not allowed on TS. Connection terminated", s->username); scp_session_destroy(s); return; @@ -107,24 +107,26 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) if (scount == 0) { /* no disconnected sessions - start a new one */ + log_message(LOG_LEVEL_DEBUG,"No disconnected sessions for this user" + "- we create a new one"); if (0 != s->client_ip) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ created session (access granted): username %s, ip %s", s->username, s->client_ip); + log_message(LOG_LEVEL_INFO, "++ created session (access granted): username %s, ip %s", s->username, s->client_ip); } else { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ created session (access granted): username %s", s->username); + log_message(LOG_LEVEL_INFO, "++ created session (access granted): username %s", s->username); } if (SCP_SESSION_TYPE_XVNC == s->type) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting Xvnc session..."); + log_message(LOG_LEVEL_INFO, "starting Xvnc session..."); display = session_start(s->width, s->height, s->bpp, s->username, s->password, data, SESMAN_SESSION_TYPE_XVNC, s->domain, s->program, s->directory, s->client_ip); } else { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "starting X11rdp session..."); + log_message(LOG_LEVEL_INFO, "starting X11rdp session..."); display = session_start(s->width, s->height, s->bpp, s->username, s->password, data, SESMAN_SESSION_TYPE_XRDP, s->domain, s->program, s->directory, s->client_ip); @@ -152,7 +154,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) /*case SCP_SERVER_STATE_FORCE_NEW:*/ /* we should check for MaxSessions */ case SCP_SERVER_STATE_SELECTION_CANCEL: - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "Connection cancelled after session listing"); + log_message( LOG_LEVEL_INFO, "Connection cancelled after session listing"); break; case SCP_SERVER_STATE_OK: /* ok, reconnecting... */ @@ -160,7 +162,7 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) if (0==sitem) { e=scp_v1s_connection_error(c, "Internal error"); - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "Cannot find session item on the chain"); + log_message(LOG_LEVEL_INFO, "Cannot find session item on the chain"); } else { @@ -169,11 +171,11 @@ scp_v1_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) e=scp_v1s_reconnect_session(c, display); if (0 != s->client_ip) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, sitem->pid, s->client_ip); + log_message(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d, ip %s", s->username, display, sitem->pid, s->client_ip); } else { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d", s->username, display, sitem->pid); + log_message(LOG_LEVEL_INFO, "++ reconnected session: username %s, display :%d.0, session_pid %d", s->username, display, sitem->pid); } g_free(sitem); } @@ -202,27 +204,27 @@ static void parseCommonStates(enum SCP_SERVER_STATES_E e, char* f) switch (e) { case SCP_SERVER_STATE_VERSION_ERR: - LOG_DBG(&(g_cfg->log), "version error") + LOG_DBG("version error") case SCP_SERVER_STATE_SIZE_ERR: /* an unknown scp version was requested, so we shut down the */ /* connection (and log the fact) */ - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, + log_message(LOG_LEVEL_WARNING, "protocol violation. connection closed."); break; case SCP_SERVER_STATE_NETWORK_ERR: - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp network error."); + log_message(LOG_LEVEL_WARNING, "libscp network error."); break; case SCP_SERVER_STATE_SEQUENCE_ERR: - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp sequence error."); + log_message(LOG_LEVEL_WARNING, "libscp sequence error."); break; case SCP_SERVER_STATE_INTERNAL_ERR: /* internal error occurred (eg. malloc() error, ecc.) */ - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "libscp internal error occurred."); + log_message(LOG_LEVEL_ERROR, "libscp internal error occurred."); break; default: /* dummy: scp_v1s_request_password won't generate any other */ /* error other than the ones before */ - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "unknown return from %s", f); + log_message(LOG_LEVEL_ALWAYS, "unknown return from %s", f); break; } } diff --git a/sesman/scp_v1_mng.c b/sesman/scp_v1_mng.c index a1773225..e4d97b77 100644 --- a/sesman/scp_v1_mng.c +++ b/sesman/scp_v1_mng.c @@ -49,7 +49,7 @@ scp_v1_mng_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) if (!data) { scp_v1s_mng_deny_connection(c, "Login failed"); - log_message(&(g_cfg->log), LOG_LEVEL_INFO, + log_message(LOG_LEVEL_INFO, "[MNG] Login failed for user %s. Connection terminated", s->username); scp_session_destroy(s); auth_end(data); @@ -60,7 +60,7 @@ scp_v1_mng_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) if (0 == access_login_mng_allowed(s->username)) { scp_v1s_mng_deny_connection(c, "Access to Terminal Server not allowed."); - log_message(&(g_cfg->log), LOG_LEVEL_INFO, + log_message(LOG_LEVEL_INFO, "[MNG] User %s not allowed on TS. Connection terminated", s->username); scp_session_destroy(s); auth_end(data); @@ -75,18 +75,18 @@ scp_v1_mng_process(struct SCP_CONNECTION* c, struct SCP_SESSION* s) switch (e) { case SCP_SERVER_STATE_MNG_ACTION: - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "Connection cancelled after session listing"); + log_message(LOG_LEVEL_INFO, "Connection cancelled after session listing"); break; case SCP_SERVER_STATE_MNG_LISTREQ: /* list disconnected sessions */ slist = session_get_byuser(NULL, &scount, SESMAN_SESSION_STATUS_ALL); - LOG_DBG(&(g_cfg->log), "sessions on TS: %d (slist: %x)", scount, slist); + LOG_DBG("sessions on TS: %d (slist: %x)", scount, slist); if (0 == slist) { // e=scp_v1s_connection_error(c, "Internal error"); - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "No sessions on Terminal Server"); + log_message(LOG_LEVEL_INFO, "No sessions on Terminal Server"); end = 0; } else @@ -114,27 +114,27 @@ static void parseCommonStates(enum SCP_SERVER_STATES_E e, char* f) switch (e) { case SCP_SERVER_STATE_VERSION_ERR: - LOG_DBG(&(g_cfg->log), "version error") + LOG_DBG("version error") case SCP_SERVER_STATE_SIZE_ERR: /* an unknown scp version was requested, so we shut down the */ /* connection (and log the fact) */ - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, + log_message(LOG_LEVEL_WARNING, "protocol violation. connection closed."); break; case SCP_SERVER_STATE_NETWORK_ERR: - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp network error."); + log_message(LOG_LEVEL_WARNING, "libscp network error."); break; case SCP_SERVER_STATE_SEQUENCE_ERR: - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "libscp sequence error."); + log_message(LOG_LEVEL_WARNING, "libscp sequence error."); break; case SCP_SERVER_STATE_INTERNAL_ERR: /* internal error occurred (eg. malloc() error, ecc.) */ - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "libscp internal error occurred."); + log_message(LOG_LEVEL_ERROR, "libscp internal error occurred."); break; default: /* dummy: scp_v1s_request_password won't generate any other */ /* error other than the ones before */ - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "unknown return from %s", f); + log_message(LOG_LEVEL_ALWAYS, "unknown return from %s", f); break; } } diff --git a/sesman/sesman.c b/sesman/sesman.c index 5a230417..1d60626c 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -54,7 +54,7 @@ sesman_main_loop(void) tbus robjs[8]; /*main program loop*/ - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "listening..."); + log_message(LOG_LEVEL_INFO, "listening..."); g_sck = g_tcp_socket(); g_tcp_set_non_blocking(g_sck); error = scp_tcp_bind(g_sck, g_cfg->listen_address, g_cfg->listen_port); @@ -103,7 +103,7 @@ sesman_main_loop(void) else { /* we've got a connection, so we pass it to scp code */ - LOG_DBG(&(g_cfg->log), "new connection"); + LOG_DBG("new connection"); thread_scp_start(in_sck); /* todo, do we have to wait here ? */ } @@ -113,13 +113,13 @@ sesman_main_loop(void) } else { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "listen error %d (%s)", + log_message(LOG_LEVEL_ERROR, "listen error %d (%s)", g_get_errno(), g_get_strerror()); } } else { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "bind error on " + log_message(LOG_LEVEL_ERROR, "bind error on " "port '%s': %d (%s)", g_cfg->listen_port, g_get_errno(), g_get_strerror()); } @@ -131,12 +131,13 @@ int DEFAULT_CC main(int argc, char** argv) { int fd; - int error; + enum logReturns error; int daemon = 1; int pid; char pid_s[8]; char text[256]; char pid_file[256]; + char cfg_file[256]; g_init("xrdp-sesman"); g_snprintf(pid_file, 255, "%s/xrdp-sesman.pid", XRDP_PID_PATH); @@ -242,7 +243,7 @@ main(int argc, char** argv) g_deinit(); g_exit(1); } - g_cfg->log.fd = -1; /* don't use logging before reading its config */ + //g_cfg->log.fd = -1; /* don't use logging before reading its config */ if (0 != config_read(g_cfg)) { g_printf("error reading config: %s\nquitting.\n", g_get_strerror()); @@ -250,18 +251,21 @@ main(int argc, char** argv) g_exit(1); } + g_snprintf(cfg_file,255,"%s/sesman.ini",XRDP_CFG_PATH); + /* starting logging subsystem */ - error = log_start(&(g_cfg->log)); + error = log_start(cfg_file,"XRDP-sesman"); if (error != LOG_STARTUP_OK) { + char buf[256] ; switch (error) { case LOG_ERROR_MALLOC: g_printf("error on malloc. cannot start logging. quitting.\n"); break; case LOG_ERROR_FILE_OPEN: - g_printf("error opening log file [%s]. quitting.\n", g_cfg->log.log_file); + g_printf("error opening log file [%s]. quitting.\n", getLogFile(buf,255)); break; } g_deinit(); @@ -269,7 +273,7 @@ main(int argc, char** argv) } /* libscp initialization */ - scp_init(&(g_cfg->log)); + scp_init(); if (daemon) { @@ -317,10 +321,10 @@ main(int argc, char** argv) fd = g_file_open(pid_file); if (-1 == fd) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, + log_message(LOG_LEVEL_ERROR, "error opening pid file[%s]: %s", pid_file, g_get_strerror()); - log_end(&(g_cfg->log)); + log_end(); g_deinit(); g_exit(1); } @@ -330,7 +334,7 @@ main(int argc, char** argv) } /* start program main loop */ - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, + log_message(LOG_LEVEL_ALWAYS, "starting sesman with pid %d", g_pid); /* make sure the /tmp/.X11-unix directory exist */ @@ -358,7 +362,7 @@ main(int argc, char** argv) if (!daemon) { - log_end(&(g_cfg->log)); + log_end(); } g_deinit(); diff --git a/sesman/sesman.ini b/sesman/sesman.ini index 9aa58581..88252a18 100644 --- a/sesman/sesman.ini +++ b/sesman/sesman.ini @@ -21,7 +21,7 @@ DisconnectedTimeLimit=0 [Logging] LogFile=/var/log/xrdp-sesman.log LogLevel=DEBUG -EnableSyslog=0 +EnableSyslog=1 SyslogLevel=DEBUG [X11rdp] diff --git a/sesman/session.c b/sesman/session.c index 2960a7f7..1557f2da 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -50,6 +50,39 @@ static tbus g_sync_data; static tui8 g_sync_type; static int g_sync_result; +/** + * Creates a string consisting of all parameters that is hosted in the param list + * @param self + * @param outstr, allocate this buffer before you use this function + * @param len the allocated len for outstr + * @return + */ +char* APP_CC +dumpItemsToString(struct list* self, char *outstr, int len) +{ + g_memset(outstr,0,len); + int index; + tbus item; + int totalLen= 0; + + if (self->count == 0) + { + g_writeln("List is empty"); + } + for (index = 0; index < self->count; index++) + { + /* +1 = one space*/ + totalLen = totalLen + g_strlen((char*)list_get_item(self, index))+1; + if(len>totalLen) + { + g_strcat(outstr,(char*)list_get_item(self, index)); + g_strcat(outstr," "); + } + } + return outstr ; +} + + /******************************************************************************/ struct session_item* DEFAULT_CC session_get_bydata(char* name, int width, int height, int bpp, int type) @@ -196,7 +229,7 @@ session_start_sessvc(int xpid, int wmpid, long data) /* new style waiting for clients */ g_sprintf(wmpid_str, "%d", wmpid); g_sprintf(xpid_str, "%d", xpid); - log_message(&(g_cfg->log), LOG_LEVEL_INFO, + log_message(LOG_LEVEL_INFO, "starting xrdp-sessvc - xpid=%s - wmpid=%s", xpid_str, wmpid_str); @@ -215,19 +248,19 @@ session_start_sessvc(int xpid, int wmpid, long data) g_execvp(exe_path, ((char**)sessvc_params->items)); /* should not get here */ - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, + log_message(LOG_LEVEL_ALWAYS, "error starting xrdp-sessvc - pid %d - xpid=%s - wmpid=%s", g_getpid(), xpid_str, wmpid_str); /* logging parameters */ /* no problem calling strerror for thread safety: other threads are blocked */ - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, description: %s", + log_message(LOG_LEVEL_DEBUG, "errno: %d, description: %s", errno, g_get_strerror()); - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "execve parameter list:"); + log_message(LOG_LEVEL_DEBUG, "execve parameter list:"); for (i = 0; i < (sessvc_params->count); i++) { - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[%d] = %s", i, + log_message(LOG_LEVEL_DEBUG, " argv[%d] = %s", i, (char*)list_get_item(sessvc_params, i)); } list_delete(sessvc_params); @@ -285,7 +318,7 @@ session_get_aval_display_from_chain(void) display++; } lock_chain_release(); - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "X server -- no display in range is available"); + log_message(LOG_LEVEL_ERROR, "X server -- no display in range is available"); return 0; } @@ -303,7 +336,7 @@ wait_for_xserver(int display) i++; if (i > 40) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, + log_message(LOG_LEVEL_ERROR, "X server for display %d startup timeout", display); break; @@ -335,6 +368,7 @@ session_start_fork(int width, int height, int bpp, char* username, struct list * xserver_params = (struct list *)NULL; time_t ltime; struct tm stime; + char execvpparams[2048]; /* initialize (zero out) local variables: */ g_memset(<ime,0,sizeof(time_t)); @@ -348,7 +382,7 @@ session_start_fork(int width, int height, int bpp, char* username, /* check to limit concurrent sessions */ if (g_session_count >= g_cfg->sess.max_sessions) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "max concurrent session limit " + log_message(LOG_LEVEL_INFO, "max concurrent session limit " "exceeded. login for user %s denied", username); return 0; } @@ -356,7 +390,7 @@ session_start_fork(int width, int height, int bpp, char* username, temp = (struct session_chain*)g_malloc(sizeof(struct session_chain), 0); if (temp == 0) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "cannot create new chain " + log_message(LOG_LEVEL_ERROR, "cannot create new chain " "element - user %s", username); return 0; } @@ -364,7 +398,7 @@ session_start_fork(int width, int height, int bpp, char* username, if (temp->item == 0) { g_free(temp); - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "cannot create new session " + log_message(LOG_LEVEL_ERROR, "cannot create new session " "item - user %s", username); return 0; } @@ -408,7 +442,7 @@ session_start_fork(int width, int height, int bpp, char* username, if (program[0] != 0) { g_execlp3(program, program, 0); - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, + log_message(LOG_LEVEL_ALWAYS, "error starting program %s for user %s - pid %d", program, username, g_getpid()); } @@ -420,16 +454,16 @@ session_start_fork(int width, int height, int bpp, char* username, if (g_file_exist(text)) { g_execlp3(text, g_cfg->user_wm, 0); - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,"error starting user " + log_message(LOG_LEVEL_ALWAYS,"error starting user " "wm for user %s - pid %d", username, g_getpid()); /* logging parameters */ - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, " + log_message(LOG_LEVEL_DEBUG, "errno: %d, " "description: %s", errno, g_get_strerror()); - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG,"execlp3 parameter " + log_message(LOG_LEVEL_DEBUG,"execlp3 parameter " "list:"); - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[0] = %s", + log_message(LOG_LEVEL_DEBUG, " argv[0] = %s", text); - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[1] = %s", + log_message(LOG_LEVEL_DEBUG, " argv[1] = %s", g_cfg->user_wm); } } @@ -438,33 +472,33 @@ session_start_fork(int width, int height, int bpp, char* username, g_sprintf(text, "%s/%s", XRDP_CFG_PATH, g_cfg->default_wm); g_execlp3(text, g_cfg->default_wm, 0); - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,"error starting default " + log_message( LOG_LEVEL_ALWAYS,"error starting default " "wm for user %s - pid %d", username, g_getpid()); /* logging parameters */ - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, description: " + log_message( LOG_LEVEL_DEBUG, "errno: %d, description: " "%s", errno, g_get_strerror()); - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG,"execlp3 parameter list:"); - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[0] = %s", + log_message(LOG_LEVEL_DEBUG,"execlp3 parameter list:"); + log_message(LOG_LEVEL_DEBUG, " argv[0] = %s", text); - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[1] = %s", + log_message(LOG_LEVEL_DEBUG, " argv[1] = %s", g_cfg->default_wm); /* still a problem starting window manager just start xterm */ g_execlp3("xterm", "xterm", 0); /* should not get here */ - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS,"error starting xterm " + log_message(LOG_LEVEL_ALWAYS,"error starting xterm " "for user %s - pid %d", username, g_getpid()); /* logging parameters */ - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, description: " + log_message(LOG_LEVEL_DEBUG, "errno: %d, description: " "%s", errno, g_get_strerror()); } else { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "another Xserver is " - "already active on display %d", display); + log_message(LOG_LEVEL_ERROR, "another Xserver might " + "already be active on display %d - see log", display); } - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG,"aborting connection..."); + log_message(LOG_LEVEL_DEBUG,"aborting connection..."); g_exit(0); } else /* parent (child sesman) */ @@ -499,6 +533,7 @@ session_start_fork(int width, int height, int bpp, char* username, /* make sure it ends with a zero */ list_add_item(xserver_params, 0); pp1 = (char**)xserver_params->items; + log_message(LOG_LEVEL_INFO,"Xvnc start:%s",dumpItemsToString(xserver_params, execvpparams, 2048)); g_execvp("Xvnc", pp1); } else if (type == SESMAN_SESSION_TYPE_XRDP) @@ -521,28 +556,29 @@ session_start_fork(int width, int height, int bpp, char* username, /* make sure it ends with a zero */ list_add_item(xserver_params, 0); pp1 = (char**)xserver_params->items; + log_message(LOG_LEVEL_INFO,"X11rdp start:%s",dumpItemsToString(xserver_params, execvpparams, 2048)); g_execvp("X11rdp", pp1); } else { - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "bad session type - " + log_message(LOG_LEVEL_ALWAYS, "bad session type - " "user %s - pid %d", username, g_getpid()); g_exit(1); } /* should not get here */ - log_message(&(g_cfg->log), LOG_LEVEL_ALWAYS, "error starting X server " + log_message(LOG_LEVEL_ALWAYS, "error starting X server " "- user %s - pid %d", username, g_getpid()); /* logging parameters */ - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "errno: %d, description: " + log_message(LOG_LEVEL_DEBUG, "errno: %d, description: " "%s", errno, g_get_strerror()); - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "execve parameter list: " + log_message(LOG_LEVEL_DEBUG, "execve parameter list size: " "%d", (xserver_params)->count); for (i=0; i<(xserver_params->count); i++) { - log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, " argv[%d] = %s", + log_message(LOG_LEVEL_DEBUG, " argv[%d] = %s", i, (char*)list_get_item(xserver_params, i)); } list_delete(xserver_params); @@ -656,7 +692,7 @@ session_kill(int pid) { if (tmp->item == 0) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "session descriptor for " + log_message(LOG_LEVEL_ERROR, "session descriptor for " "pid %d is null!", pid); if (prev == 0) { @@ -676,7 +712,7 @@ session_kill(int pid) if (tmp->item->pid == pid) { /* deleting the session */ - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "++ terminated session: username %s, display :%d.0, session_pid %d, ip %s", tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->client_ip); + log_message(LOG_LEVEL_INFO, "++ terminated session: username %s, display :%d.0, session_pid %d, ip %s", tmp->item->name, tmp->item->display, tmp->item->pid, tmp->item->client_ip); g_free(tmp->item); if (prev == 0) { @@ -720,7 +756,7 @@ session_sigkill_all() { if (tmp->item == 0) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "found null session " + log_message(LOG_LEVEL_ERROR, "found null session " "descriptor!"); } else @@ -746,7 +782,7 @@ session_get_bypid(int pid) dummy = g_malloc(sizeof(struct session_item), 1); if (0 == dummy) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "internal error", pid); + log_message(LOG_LEVEL_ERROR, "internal error", pid); return 0; } @@ -758,7 +794,7 @@ session_get_bypid(int pid) { if (tmp->item == 0) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "session descriptor for " + log_message(LOG_LEVEL_ERROR, "session descriptor for " "pid %d is null!", pid); /*THREAD-FIX release chain lock */ lock_chain_release(); @@ -800,10 +836,10 @@ session_get_byuser(char* user, int* cnt, unsigned char flags) tmp = g_sessions; while (tmp != 0) { - LOG_DBG(&(g_cfg->log), "user: %s", user); + LOG_DBG("user: %s", user); if ((NULL == user) || (!g_strncasecmp(user, tmp->item->name, 256))) { - LOG_DBG(&(g_cfg->log), "session_get_byuser: status=%d, flags=%d, " + LOG_DBG("session_get_byuser: status=%d, flags=%d, " "result=%d", (tmp->item->status), flags, ((tmp->item->status) & flags)); if ((tmp->item->status) & flags) diff --git a/sesman/sig.c b/sesman/sig.c index 24f2e81c..151c0c57 100644 --- a/sesman/sig.c +++ b/sesman/sig.c @@ -40,15 +40,15 @@ sig_sesman_shutdown(int sig) { char pid_file[256]; - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "shutting down sesman %d", 1); + log_message(LOG_LEVEL_INFO, "shutting down sesman %d", 1); if (g_getpid() != g_pid) { - LOG_DBG(&(g_cfg->log), "g_getpid() [%d] differs from g_pid [%d]", (g_getpid()), g_pid); + LOG_DBG("g_getpid() [%d] differs from g_pid [%d]", (g_getpid()), g_pid); return; } - LOG_DBG(&(g_cfg->log), " - getting signal %d pid %d", sig, g_getpid()); + LOG_DBG(" - getting signal %d pid %d", sig, g_getpid()); g_set_wait_obj(g_term_event); @@ -66,51 +66,55 @@ sig_sesman_reload_cfg(int sig) { int error; struct config_sesman *cfg; + char cfg_file[256]; - log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "receiving SIGHUP %d", 1); + log_message(LOG_LEVEL_WARNING, "receiving SIGHUP %d", 1); if (g_getpid() != g_pid) { - LOG_DBG(&(g_cfg->log), "g_getpid() [%d] differs from g_pid [%d]", g_getpid(), g_pid); + LOG_DBG("g_getpid() [%d] differs from g_pid [%d]", g_getpid(), g_pid); return; } cfg = g_malloc(sizeof(struct config_sesman), 1); if (0 == cfg) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "error creating new config: - keeping old cfg"); + log_message(LOG_LEVEL_ERROR, "error creating new config: - keeping old cfg"); return; } if (config_read(cfg) != 0) { - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "error reading config - keeping old cfg"); + log_message(LOG_LEVEL_ERROR, "error reading config - keeping old cfg"); return; } /* stop logging subsystem */ - log_end(&(g_cfg->log)); + log_end(); /* replace old config with new readed one */ g_cfg = cfg; + + g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH); /* start again logging subsystem */ - error = log_start(&(g_cfg->log)); + error = log_start(cfg_file,"XRDP-sesman"); if (error != LOG_STARTUP_OK) { + char buf[256]; switch (error) { case LOG_ERROR_MALLOC: g_printf("error on malloc. cannot restart logging. log stops here, sorry.\n"); break; case LOG_ERROR_FILE_OPEN: - g_printf("error reopening log file [%s]. log stops here, sorry.\n", g_cfg->log.log_file); + g_printf("error reopening log file [%s]. log stops here, sorry.\n", getLogFile(buf,255)); break; } } - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "configuration reloaded, log subsystem restarted"); + log_message(LOG_LEVEL_INFO, "configuration reloaded, log subsystem restarted"); } /******************************************************************************/ @@ -166,27 +170,27 @@ sig_handler_thread(void* arg) case SIGHUP: //reload cfg //we must stop & restart logging, or copy logging cfg!!!! - LOG_DBG(&(g_cfg->log), "sesman received SIGHUP", 0); + LOG_DBG("sesman received SIGHUP", 0); //return 0; break; case SIGCHLD: /* a session died */ - LOG_DBG(&(g_cfg->log), "sesman received SIGCHLD", 0); + LOG_DBG("sesman received SIGCHLD", 0); sig_sesman_session_end(SIGCHLD); break; case SIGINT: /* we die */ - LOG_DBG(&(g_cfg->log), "sesman received SIGINT", 0); + LOG_DBG("sesman received SIGINT", 0); sig_sesman_shutdown(recv_signal); break; case SIGKILL: /* we die */ - LOG_DBG(&(g_cfg->log), "sesman received SIGKILL", 0); + LOG_DBG("sesman received SIGKILL", 0); sig_sesman_shutdown(recv_signal); break; case SIGTERM: /* we die */ - LOG_DBG(&(g_cfg->log), "sesman received SIGTERM", 0); + LOG_DBG("sesman received SIGTERM", 0); sig_sesman_shutdown(recv_signal); break; } diff --git a/sesman/thread.c b/sesman/thread.c index 986a5d27..4c266637 100644 --- a/sesman/thread.c +++ b/sesman/thread.c @@ -62,14 +62,14 @@ thread_sighandler_start(void) sigaddset(&waitmask, SIGFPE); pthread_sigmask(SIG_UNBLOCK, &waitmask, NULL); - log_message(&(g_cfg->log), LOG_LEVEL_INFO,"starting signal handling thread..."); + log_message(LOG_LEVEL_INFO,"starting signal handling thread..."); ret = pthread_create(&g_thread_sighandler, NULL, sig_handler_thread, ""); pthread_detach(g_thread_sighandler); if (ret == 0) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "signal handler thread started successfully"); + log_message(LOG_LEVEL_INFO, "signal handler thread started successfully"); return 0; } @@ -77,16 +77,16 @@ thread_sighandler_start(void) switch (ret) { case EINVAL: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid attributes for signal handling thread (creation returned EINVAL)"); + log_message(LOG_LEVEL_ERROR, "invalid attributes for signal handling thread (creation returned EINVAL)"); break; case EAGAIN: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "not enough resources to start signal handling thread (creation returned EAGAIN)"); + log_message(LOG_LEVEL_ERROR, "not enough resources to start signal handling thread (creation returned EAGAIN)"); break; case EPERM: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid permissions for signal handling thread (creation returned EPERM)"); + log_message(LOG_LEVEL_ERROR, "invalid permissions for signal handling thread (creation returned EPERM)"); break; default: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "unknown error starting signal handling thread"); + log_message(LOG_LEVEL_ERROR, "unknown error starting signal handling thread"); } return 1; @@ -116,16 +116,16 @@ thread_session_update_start(void) switch (ret) { case EINVAL: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid attributes for session update thread (creation returned EINVAL)"); + log_message(LOG_LEVEL_ERROR, "invalid attributes for session update thread (creation returned EINVAL)"); break; case EAGAIN: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "not enough resources to start session update thread (creation returned EAGAIN)"); + log_message(LOG_LEVEL_ERROR, "not enough resources to start session update thread (creation returned EAGAIN)"); break; case EPERM: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid permissions for session update thread (creation returned EPERM)"); + log_message(LOG_LEVEL_ERROR, "invalid permissions for session update thread (creation returned EPERM)"); break; default: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "unknown error starting session update thread"); + log_message(LOG_LEVEL_ERROR, "unknown error starting session update thread"); } return 1; @@ -150,7 +150,7 @@ thread_scp_start(int skt) if (ret == 0) { - log_message(&(g_cfg->log), LOG_LEVEL_INFO, "scp thread on sck %d started successfully", skt); + log_message(LOG_LEVEL_INFO, "scp thread on sck %d started successfully", skt); return 0; } @@ -158,16 +158,16 @@ thread_scp_start(int skt) switch (ret) { case EINVAL: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid attributes for scp thread on sck %d (creation returned EINVAL)", skt); + log_message(LOG_LEVEL_ERROR, "invalid attributes for scp thread on sck %d (creation returned EINVAL)", skt); break; case EAGAIN: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "not enough resources to start scp thread on sck %d (creation returned EAGAIN)", skt); + log_message(LOG_LEVEL_ERROR, "not enough resources to start scp thread on sck %d (creation returned EAGAIN)", skt); break; case EPERM: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "invalid permissions for scp thread on sck %d (creation returned EPERM)", skt); + log_message(LOG_LEVEL_ERROR, "invalid permissions for scp thread on sck %d (creation returned EPERM)", skt); break; default: - log_message(&(g_cfg->log), LOG_LEVEL_ERROR, "unknown error starting scp thread on sck %d"); + log_message(LOG_LEVEL_ERROR, "unknown error starting scp thread on sck %d"); } return 1; diff --git a/sesman/tools/sesadmin.c b/sesman/tools/sesadmin.c index 4c612316..7fac3d47 100644 --- a/sesman/tools/sesadmin.c +++ b/sesman/tools/sesadmin.c @@ -50,7 +50,7 @@ int main(int argc, char** argv) logging.log_file = g_strdup("xrdp-sesadmin.log"); logging.log_level = LOG_LEVEL_DEBUG; logging.enable_syslog = 0; - log_start(&logging); + log_start_from_param(&logging); for (idx = 0; idx < argc; idx++) { @@ -110,11 +110,11 @@ int main(int argc, char** argv) s = scp_session_create(); c = scp_connection_create(sock); - LOG_DBG(&logging, "Connecting to %s:%s with user %s (%s)\n", serv, port, user, pass); + LOG_DBG("Connecting to %s:%s with user %s (%s)\n", serv, port, user, pass); if (0 != g_tcp_connect(sock, serv, port)) { - LOG_DBG(&logging, "g_tcp_connect() error\n"); + LOG_DBG("g_tcp_connect() error\n"); return 1; } @@ -127,7 +127,7 @@ int main(int argc, char** argv) if (SCP_CLIENT_STATE_OK != e) { - LOG_DBG(&logging, "libscp error connecting: %s %d\n", s->errstr, (int)e); + LOG_DBG("libscp error connecting: %s %d\n", s->errstr, (int)e); } if (0 == g_strncmp(cmnd, "list", 5)) diff --git a/sesman/tools/sestest.c b/sesman/tools/sestest.c index 4382e160..1ba119e0 100644 --- a/sesman/tools/sestest.c +++ b/sesman/tools/sestest.c @@ -34,7 +34,7 @@ int main(int argc, char** argv) log.log_level=99; log.program_name=g_strdup("sestest"); log.log_file=g_strdup("sestest.log"); - log_start(&log); + log_start_from_param(&log); scp_init(&log); sock=g_tcp_socket(); diff --git a/sesman/verify_user.c b/sesman/verify_user.c index cdc60b47..ffe1c04d 100644 --- a/sesman/verify_user.c +++ b/sesman/verify_user.c @@ -310,13 +310,13 @@ auth_account_disabled(struct spwd* stp) today=g_time1()/SECS_PER_DAY; - LOG_DBG(&(g_cfg->log), "last %d",stp->sp_lstchg); - LOG_DBG(&(g_cfg->log), "min %d",stp->sp_min); - LOG_DBG(&(g_cfg->log), "max %d",stp->sp_max); - LOG_DBG(&(g_cfg->log), "inact %d",stp->sp_inact); - LOG_DBG(&(g_cfg->log), "warn %d",stp->sp_warn); - LOG_DBG(&(g_cfg->log), "expire %d",stp->sp_expire); - LOG_DBG(&(g_cfg->log), "today %d",today); + LOG_DBG("last %d",stp->sp_lstchg); + LOG_DBG("min %d",stp->sp_min); + LOG_DBG("max %d",stp->sp_max); + LOG_DBG("inact %d",stp->sp_inact); + LOG_DBG("warn %d",stp->sp_warn); + LOG_DBG("expire %d",stp->sp_expire); + LOG_DBG("today %d",today); if ((stp->sp_expire != -1) && (today >= stp->sp_expire)) { |