sesman: added SessionVariables to sesman.ini and some indent cleanup

ulab-next
Jay Sorg 11 years ago
parent 3819fa5e72
commit 49fcc23673

@ -88,6 +88,8 @@ config_read(struct config_sesman *cfg)
/* read session config */ /* read session config */
config_read_sessions(fd, &(cfg->sess), param_n, param_v); config_read_sessions(fd, &(cfg->sess), param_n, param_v);
config_read_session_variables(fd, cfg, param_n, param_v);
/* cleanup */ /* cleanup */
list_delete(sec); list_delete(sec);
list_delete(param_v); list_delete(param_v);
@ -507,3 +509,39 @@ config_read_vnc_params(int file, struct config_sesman *cs, struct list *param_n,
return 0; return 0;
} }
/******************************************************************************/
int DEFAULT_CC
config_read_session_variables(int file, struct config_sesman *cs,
struct list *param_n, struct list *param_v)
{
int i;
list_clear(param_v);
list_clear(param_n);
cs->session_variables1 = list_create();
cs->session_variables2 = list_create();
file_read_section(file, SESMAN_CFG_SESSION_VARIABLES, param_n, param_v);
for (i = 0; i < param_n->count; i++)
{
list_add_item(cs->session_variables1,
(tintptr) g_strdup((char *) list_get_item(param_n, i)));
list_add_item(cs->session_variables2,
(tintptr) g_strdup((char *) list_get_item(param_v, i)));
}
/* printing security config */
g_writeln("%s parameters:", SESMAN_CFG_SESSION_VARIABLES);
for (i = 0; i < cs->session_variables1->count; i++)
{
g_writeln(" Parameter %02d %s=%s", i,
(char *) list_get_item(cs->session_variables1, i),
(char *) list_get_item(cs->session_variables2, i));
}
return 0;
}

@ -45,6 +45,8 @@
#define SESMAN_CFG_XORG_PARAMS "Xorg" #define SESMAN_CFG_XORG_PARAMS "Xorg"
#define SESMAN_CFG_VNC_PARAMS "Xvnc" #define SESMAN_CFG_VNC_PARAMS "Xvnc"
#define SESMAN_CFG_SESSION_VARIABLES "SessionVariables"
/* /*
#define SESMAN_CFG_LOGGING "Logging" #define SESMAN_CFG_LOGGING "Logging"
#define SESMAN_CFG_LOG_FILE "LogFile" #define SESMAN_CFG_LOG_FILE "LogFile"
@ -239,6 +241,9 @@ struct config_sesman
* @brief Session configuration options struct * @brief Session configuration options struct
*/ */
struct config_sessions sess; struct config_sessions sess;
struct list* session_variables1;
struct list* session_variables2;
}; };
/** /**
@ -349,4 +354,8 @@ int DEFAULT_CC
config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n, config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n,
struct list* param_v); struct list* param_v);
int DEFAULT_CC
config_read_session_variables(int file, struct config_sesman *cs,
struct list *param_n, struct list *param_v);
#endif #endif

@ -24,6 +24,8 @@
* *
*/ */
#include "list.h"
#include "sesman.h" #include "sesman.h"
#include "sys/types.h" #include "sys/types.h"
@ -60,12 +62,16 @@ env_check_password_file(char *filename, char *password)
/******************************************************************************/ /******************************************************************************/
int DEFAULT_CC int DEFAULT_CC
env_set_user(char *username, char *passwd_file, int display) env_set_user(char *username, char *passwd_file, int display,
struct list *env_names, struct list* env_values)
{ {
int error; int error;
int pw_uid; int pw_uid;
int pw_gid; int pw_gid;
int uid; int uid;
int index;
char *name;
char *value;
char pw_shell[256]; char pw_shell[256];
char pw_dir[256]; char pw_dir[256];
char pw_gecos[256]; char pw_gecos[256];
@ -96,7 +102,7 @@ env_set_user(char *username, char *passwd_file, int display)
{ {
g_clearenv(); g_clearenv();
g_setenv("SHELL", pw_shell, 1); g_setenv("SHELL", pw_shell, 1);
g_setenv("PATH", "/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin", 1); g_setenv("PATH", "/bin:/usr/bin:/usr/local/bin", 1);
g_setenv("USER", username, 1); g_setenv("USER", username, 1);
g_sprintf(text, "%d", uid); g_sprintf(text, "%d", uid);
g_setenv("UID", text, 1); g_setenv("UID", text, 1);
@ -106,6 +112,16 @@ env_set_user(char *username, char *passwd_file, int display)
g_setenv("DISPLAY", text, 1); g_setenv("DISPLAY", text, 1);
g_setenv("LANG", "en_US.UTF-8", 1); g_setenv("LANG", "en_US.UTF-8", 1);
g_setenv("XRDP_SESSION", "1", 1); g_setenv("XRDP_SESSION", "1", 1);
if ((env_names != 0) && (env_values != 0) &&
(env_names->count == env_values->count))
{
for (index = 0; index < env_names->count; index++)
{
name = (char *) list_get_item(env_names, index),
value = (char *) list_get_item(env_values, index),
g_setenv(name, value, 1);
}
}
if (passwd_file != 0) if (passwd_file != 0)
{ {

@ -27,6 +27,8 @@
#ifndef ENV_H #ifndef ENV_H
#define ENV_H #define ENV_H
#include "list.h"
/** /**
* *
* @brief Creates vnc password file * @brief Creates vnc password file
@ -48,6 +50,7 @@ env_check_password_file(char* filename, char* password);
* *
*/ */
int DEFAULT_CC int DEFAULT_CC
env_set_user(char* username, char* passwd_file, int display); env_set_user(char* username, char* passwd_file, int display,
struct list *env_names, struct list* env_values);
#endif #endif

@ -91,3 +91,6 @@ param8=tcp
[Chansrv] [Chansrv]
# drive redirection, defaults to xrdp_client if not set # drive redirection, defaults to xrdp_client if not set
FuseMountName=thinclient_drives FuseMountName=thinclient_drives
[SessionVariables]
PULSE_CONFIG=/etc/xrdp/pulse/daemon.conf

@ -288,7 +288,8 @@ session_start_sessvc(int xpid, int wmpid, long data, char *username, int display
list_add_item(sessvc_params, (long)g_strdup(wmpid_str)); list_add_item(sessvc_params, (long)g_strdup(wmpid_str));
list_add_item(sessvc_params, 0); /* mandatory */ list_add_item(sessvc_params, 0); /* mandatory */
env_set_user(username, 0, display); env_set_user(username, 0, display,
g_cfg->session_variables1, g_cfg->session_variables2);
/* executing sessvc */ /* executing sessvc */
g_execvp(exe_path, ((char **)sessvc_params->items)); g_execvp(exe_path, ((char **)sessvc_params->items));
@ -501,7 +502,9 @@ session_start_fork(int width, int height, int bpp, char *username,
} }
else if (pampid == 0) /* child: X11/client */ else if (pampid == 0) /* child: X11/client */
{ {
env_set_user(username, 0, display); env_set_user(username, 0, display,
g_cfg->session_variables1,
g_cfg->session_variables2);
if (x_server_running(display)) if (x_server_running(display))
{ {
auth_set_env(data); auth_set_env(data);
@ -594,7 +597,9 @@ session_start_fork(int width, int height, int bpp, char *username,
} }
else if (xpid == 0) /* child */ else if (xpid == 0) /* child */
{ {
env_set_user(username, passwd_file, display); env_set_user(username, passwd_file, display,
g_cfg->session_variables1,
g_cfg->session_variables2);
env_check_password_file(passwd_file, password); env_check_password_file(passwd_file, password);
g_snprintf(text, 255, "%d", g_cfg->sess.max_idle_time); g_snprintf(text, 255, "%d", g_cfg->sess.max_idle_time);
@ -774,7 +779,8 @@ session_reconnect_fork(int display, char *username)
} }
else if (pid == 0) else if (pid == 0)
{ {
env_set_user(username, 0, display); env_set_user(username, 0, display,
g_cfg->session_variables1, g_cfg->session_variables2);
g_snprintf(text, 255, "%s/%s", XRDP_CFG_PATH, "reconnectwm.sh"); g_snprintf(text, 255, "%s/%s", XRDP_CFG_PATH, "reconnectwm.sh");
if (g_file_exist(text)) if (g_file_exist(text))

Loading…
Cancel
Save