From 7cdd7191a4243d04b14315f9ae73f1bebaff9953 Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Mon, 18 Sep 2006 04:40:43 +0000 Subject: added ability to put extra Xserver parameters in sesman.ini --- sesman/config.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- sesman/config.h | 11 +++++++++++ sesman/sesman.c | 5 +++++ sesman/sesman.ini | 8 ++++++++ sesman/session.c | 45 +++++++++++++++++++++++++++++++++++++++------ 5 files changed, 113 insertions(+), 7 deletions(-) diff --git a/sesman/config.c b/sesman/config.c index 9ff5d500..8a11ef09 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -62,7 +62,8 @@ config_read(struct config_sesman* cfg) fd = g_file_open(SESMAN_CFG_FILE); if (-1 == fd) { - g_printf("sesman: error reading config: %s\r\n", SESMAN_CFG_FILE); + log_message(LOG_LEVEL_ALWAYS, "error opening %s in \ +config_read", SESMAN_CFG_FILE); return 1; } g_memset(cfg, 0, sizeof(struct config_sesman)); @@ -90,6 +91,7 @@ config_read(struct config_sesman* cfg) list_delete(sec); list_delete(param_v); list_delete(param_n); + g_file_close(fd); return 0; } @@ -327,3 +329,50 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n, return 0; } +/******************************************************************************/ +/* returns in params a list of parameters that need to be freed */ +/* returns error */ +int DEFAULT_CC +config_read_xserver_params(int server_type, struct list* param_array) +{ + struct list* names; + struct list* params; + int fd; + char section_name[16]; + + if (server_type == SESMAN_SESSION_TYPE_XRDP) + { + g_strncpy(section_name, "X11rdp", 15); + } + else if (server_type == SESMAN_SESSION_TYPE_XVNC) + { + g_strncpy(section_name, "Xvnc", 15); + } + else + { + /* error */ + log_message(LOG_LEVEL_ALWAYS, "error unknown type in \ +config_read_xserver_params"); + return 1; + } + fd = g_file_open(SESMAN_CFG_FILE); + if (-1 == fd) + { + /* error */ + log_message(LOG_LEVEL_ALWAYS, "error opening %s in \ +config_read_xserver_params %s", SESMAN_CFG_FILE, g_get_strerror()); + return 1; + } + names = list_create(); + names->auto_free = 1; + params = list_create(); + params->auto_free = 1; + if (file_read_section(fd, section_name, names, params) == 0) + { + list_append_list_strdup(params, param_array, 0); + } + g_file_close(fd); + list_delete(names); + list_delete(params); + return 0; +} diff --git a/sesman/config.h b/sesman/config.h index fe3926e1..b2665010 100644 --- a/sesman/config.h +++ b/sesman/config.h @@ -238,4 +238,15 @@ int DEFAULT_CC config_read_sessions(int file, struct config_sessions* ss, struct list* param_n, struct list* param_v); +/** + * + * @brief Reads sesman [X11rdp, Xvnc, ...] configuration section + * @param server_type integer representing server type + * @param param_array pointer to list to add strings to + * @return 0 on success, 1 on failure + * + */ +int DEFAULT_CC +config_read_xserver_params(int server_type, struct list* param_array); + #endif diff --git a/sesman/sesman.c b/sesman/sesman.c index 0b6bf1b6..c02b5895 100644 --- a/sesman/sesman.c +++ b/sesman/sesman.c @@ -148,6 +148,11 @@ main(int argc, char** argv) } error = g_file_read(fd, pid_s, 7); + if (0 != error) + { + g_printf("error reading pid file: %s\n", g_get_strerror()); + } + g_file_close(fd); pid = g_atoi(pid_s); error = g_sigterm(pid); diff --git a/sesman/sesman.ini b/sesman/sesman.ini index 4c5f5a18..6f8dd701 100644 --- a/sesman/sesman.ini +++ b/sesman/sesman.ini @@ -20,3 +20,11 @@ LogFile=./sesman.log LogLevel=DEBUG EnableSyslog=0 SyslogLevel=DEBUG + +[X11rdp] +param1=-bs +param2=-ac + +[Xvnc] +param1=-bs +param2=-ac \ No newline at end of file diff --git a/sesman/session.c b/sesman/session.c index 682a469f..5fe72555 100644 --- a/sesman/session.c +++ b/sesman/session.c @@ -123,7 +123,9 @@ session_start(int width, int height, int bpp, char* username, char* password, char cur_dir[256]; char text[256]; char passwd_file[256]; + char** pp1; struct session_chain* temp; + struct list* xserver_params; /*THREAD-FIX lock to control g_session_count*/ lock_chain_acquire(); @@ -139,7 +141,7 @@ for user %s denied", username); /*THREAD-FIX unlock chain*/ lock_chain_release(); - + temp = (struct session_chain*)g_malloc(sizeof(struct session_chain), 0); if (temp == 0) { @@ -230,14 +232,45 @@ for user %s denied", username); env_check_password_file(passwd_file, password); if (type == SESMAN_SESSION_TYPE_XVNC) { - g_execlp13("Xvnc", "Xvnc", screen, "-geometry", geometry, - "-depth", depth, "-bs", "-ac", "-rfbauth", passwd_file, - 0, 0); + xserver_params = list_create(); + xserver_params->auto_free = 1; + /* these are the must have parameters */ + list_add_item(xserver_params, (long)g_strdup("Xvnc")); + list_add_item(xserver_params, (long)g_strdup(screen)); + list_add_item(xserver_params, (long)g_strdup("-geometry")); + list_add_item(xserver_params, (long)g_strdup(geometry)); + list_add_item(xserver_params, (long)g_strdup("-depth")); + list_add_item(xserver_params, (long)g_strdup(depth)); + list_add_item(xserver_params, (long)g_strdup("-rfbauth")); + list_add_item(xserver_params, (long)g_strdup(passwd_file)); + /* additional parameters from sesman.ini file */ + config_read_xserver_params(SESMAN_SESSION_TYPE_XVNC, + xserver_params); + /* make sure it ends with a zero */ + list_add_item(xserver_params, 0); + pp1 = (char**)xserver_params->items; + g_execvp("Xvnc", pp1); + list_delete(xserver_params); } else if (type == SESMAN_SESSION_TYPE_XRDP) { - g_execlp11("X11rdp", "X11rdp", screen, "-geometry", geometry, - "-depth", depth, "-bs", "-ac", 0, 0); + xserver_params = list_create(); + xserver_params->auto_free = 1; + /* these are the must have parameters */ + list_add_item(xserver_params, (long)g_strdup("X11rdp")); + list_add_item(xserver_params, (long)g_strdup(screen)); + list_add_item(xserver_params, (long)g_strdup("-geometry")); + list_add_item(xserver_params, (long)g_strdup(geometry)); + list_add_item(xserver_params, (long)g_strdup("-depth")); + list_add_item(xserver_params, (long)g_strdup(depth)); + /* additional parameters from sesman.ini file */ + config_read_xserver_params(SESMAN_SESSION_TYPE_XRDP, + xserver_params); + /* make sure it ends with a zero */ + list_add_item(xserver_params, 0); + pp1 = (char**)xserver_params->items; + g_execvp("X11rdp", pp1); + list_delete(xserver_params); } else { -- cgit v1.2.1