added ability to put extra Xserver parameters in sesman.ini

ulab-original
jsorg71 18 years ago
parent acc5edf33d
commit 7cdd7191a4

@ -62,7 +62,8 @@ config_read(struct config_sesman* cfg)
fd = g_file_open(SESMAN_CFG_FILE); fd = g_file_open(SESMAN_CFG_FILE);
if (-1 == fd) 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; return 1;
} }
g_memset(cfg, 0, sizeof(struct config_sesman)); g_memset(cfg, 0, sizeof(struct config_sesman));
@ -90,6 +91,7 @@ config_read(struct config_sesman* cfg)
list_delete(sec); list_delete(sec);
list_delete(param_v); list_delete(param_v);
list_delete(param_n); list_delete(param_n);
g_file_close(fd);
return 0; return 0;
} }
@ -327,3 +329,50 @@ config_read_sessions(int file, struct config_sessions* se, struct list* param_n,
return 0; 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;
}

@ -238,4 +238,15 @@ int DEFAULT_CC
config_read_sessions(int file, struct config_sessions* ss, config_read_sessions(int file, struct config_sessions* ss,
struct list* param_n, struct list* param_v); 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 #endif

@ -148,6 +148,11 @@ main(int argc, char** argv)
} }
error = g_file_read(fd, pid_s, 7); 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); pid = g_atoi(pid_s);
error = g_sigterm(pid); error = g_sigterm(pid);

@ -20,3 +20,11 @@ LogFile=./sesman.log
LogLevel=DEBUG LogLevel=DEBUG
EnableSyslog=0 EnableSyslog=0
SyslogLevel=DEBUG SyslogLevel=DEBUG
[X11rdp]
param1=-bs
param2=-ac
[Xvnc]
param1=-bs
param2=-ac

@ -123,7 +123,9 @@ session_start(int width, int height, int bpp, char* username, char* password,
char cur_dir[256]; char cur_dir[256];
char text[256]; char text[256];
char passwd_file[256]; char passwd_file[256];
char** pp1;
struct session_chain* temp; struct session_chain* temp;
struct list* xserver_params;
/*THREAD-FIX lock to control g_session_count*/ /*THREAD-FIX lock to control g_session_count*/
lock_chain_acquire(); lock_chain_acquire();
@ -230,14 +232,45 @@ for user %s denied", username);
env_check_password_file(passwd_file, password); env_check_password_file(passwd_file, password);
if (type == SESMAN_SESSION_TYPE_XVNC) if (type == SESMAN_SESSION_TYPE_XVNC)
{ {
g_execlp13("Xvnc", "Xvnc", screen, "-geometry", geometry, xserver_params = list_create();
"-depth", depth, "-bs", "-ac", "-rfbauth", passwd_file, xserver_params->auto_free = 1;
0, 0); /* 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) else if (type == SESMAN_SESSION_TYPE_XRDP)
{ {
g_execlp11("X11rdp", "X11rdp", screen, "-geometry", geometry, xserver_params = list_create();
"-depth", depth, "-bs", "-ac", 0, 0); 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 else
{ {

Loading…
Cancel
Save