summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sesman/config.c38
-rw-r--r--sesman/config.h15
-rw-r--r--sesman/env.c20
-rw-r--r--sesman/env.h5
-rw-r--r--sesman/libscp/libscp_session.c14
-rw-r--r--sesman/libscp/libscp_v0.c14
-rw-r--r--sesman/sesman.ini3
-rw-r--r--sesman/session.c14
8 files changed, 99 insertions, 24 deletions
diff --git a/sesman/config.c b/sesman/config.c
index 8fa6e86a..5a904fc3 100644
--- a/sesman/config.c
+++ b/sesman/config.c
@@ -88,6 +88,8 @@ config_read(struct config_sesman *cfg)
/* read session config */
config_read_sessions(fd, &(cfg->sess), param_n, param_v);
+ config_read_session_variables(fd, cfg, param_n, param_v);
+
/* cleanup */
list_delete(sec);
list_delete(param_v);
@@ -507,3 +509,39 @@ config_read_vnc_params(int file, struct config_sesman *cs, struct list *param_n,
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;
+}
diff --git a/sesman/config.h b/sesman/config.h
index 31ac7256..08d84ce1 100644
--- a/sesman/config.h
+++ b/sesman/config.h
@@ -45,6 +45,8 @@
#define SESMAN_CFG_XORG_PARAMS "Xorg"
#define SESMAN_CFG_VNC_PARAMS "Xvnc"
+#define SESMAN_CFG_SESSION_VARIABLES "SessionVariables"
+
/*
#define SESMAN_CFG_LOGGING "Logging"
#define SESMAN_CFG_LOG_FILE "LogFile"
@@ -221,13 +223,13 @@ struct config_sesman
* @var log
* @brief Log configuration struct
*/
-
+
struct list* xorg_params;
/**
* @var log
* @brief Log configuration struct
*/
-
+
//struct log_config log;
/**
* @var sec
@@ -239,6 +241,9 @@ struct config_sesman
* @brief Session configuration options struct
*/
struct config_sessions sess;
+
+ struct list* session_variables1;
+ struct list* session_variables2;
};
/**
@@ -334,7 +339,7 @@ config_read_rdp_params(int file, struct config_sesman* cs, struct list* param_n,
int DEFAULT_CC
config_read_xorg_params(int file, struct config_sesman* cs, struct list* param_n,
struct list* param_v);
-
+
/**
*
* @brief Reads sesman [Xvnc] configuration section
@@ -349,4 +354,8 @@ int DEFAULT_CC
config_read_vnc_params(int file, struct config_sesman* cs, struct list* param_n,
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
diff --git a/sesman/env.c b/sesman/env.c
index b650d0b3..26d1a4f7 100644
--- a/sesman/env.c
+++ b/sesman/env.c
@@ -24,6 +24,8 @@
*
*/
+#include "list.h"
+
#include "sesman.h"
#include "sys/types.h"
@@ -60,12 +62,16 @@ env_check_password_file(char *filename, char *password)
/******************************************************************************/
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 pw_uid;
int pw_gid;
int uid;
+ int index;
+ char *name;
+ char *value;
char pw_shell[256];
char pw_dir[256];
char pw_gecos[256];
@@ -96,7 +102,7 @@ env_set_user(char *username, char *passwd_file, int display)
{
g_clearenv();
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_sprintf(text, "%d", uid);
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("LANG", "en_US.UTF-8", 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)
{
diff --git a/sesman/env.h b/sesman/env.h
index e70bfe6a..50473a01 100644
--- a/sesman/env.h
+++ b/sesman/env.h
@@ -27,6 +27,8 @@
#ifndef ENV_H
#define ENV_H
+#include "list.h"
+
/**
*
* @brief Creates vnc password file
@@ -48,6 +50,7 @@ env_check_password_file(char* filename, char* password);
*
*/
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
diff --git a/sesman/libscp/libscp_session.c b/sesman/libscp/libscp_session.c
index 8f5841a5..d25fc64a 100644
--- a/sesman/libscp/libscp_session.c
+++ b/sesman/libscp/libscp_session.c
@@ -58,19 +58,19 @@ scp_session_set_type(struct SCP_SESSION *s, tui8 type)
case SCP_SESSION_TYPE_XVNC:
s->type = SCP_SESSION_TYPE_XVNC;
break;
-
+
case SCP_SESSION_TYPE_XRDP:
s->type = SCP_SESSION_TYPE_XRDP;
break;
-
+
case SCP_SESSION_TYPE_XORG:
- s->type = SCP_SESSION_TYPE_XORG;
- break;
-
+ s->type = SCP_SESSION_TYPE_XORG;
+ break;
+
case SCP_GW_AUTHENTICATION:
s->type = SCP_GW_AUTHENTICATION;
break;
-
+
case SCP_SESSION_TYPE_MANAGE:
s->type = SCP_SESSION_TYPE_MANAGE;
s->mng = (struct SCP_MNG_DATA *)g_malloc(sizeof(struct SCP_MNG_DATA), 1);
@@ -82,7 +82,7 @@ scp_session_set_type(struct SCP_SESSION *s, tui8 type)
}
break;
-
+
default:
log_message(LOG_LEVEL_WARNING, "[session:%d] set_type: unknown type", __LINE__);
return 1;
diff --git a/sesman/libscp/libscp_v0.c b/sesman/libscp/libscp_v0.c
index eab616ff..7260244e 100644
--- a/sesman/libscp/libscp_v0.c
+++ b/sesman/libscp/libscp_v0.c
@@ -59,7 +59,7 @@ scp_v0c_connect(struct SCP_CONNECTION *c, struct SCP_SESSION *s)
else if (s->type == SCP_SESSION_TYPE_XORG)
{
out_uint16_be(c->out_s, 20);
- }
+ }
else
{
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: network error", __LINE__);
@@ -217,14 +217,14 @@ scp_v0s_accept(struct SCP_CONNECTION *c, struct SCP_SESSION **s, int skipVchk)
}
else if (code == 20)
{
- scp_session_set_type(session, SCP_SESSION_TYPE_XORG);
- }
- else
- {
+ scp_session_set_type(session, SCP_SESSION_TYPE_XORG);
+ }
+ else
+ {
log_message(LOG_LEVEL_WARNING, "[v0:%d] connection aborted: "
"invalid code in xrdp.ini file: code=%d", __LINE__, code);
- return SCP_SERVER_STATE_INTERNAL_ERR;
- }
+ return SCP_SERVER_STATE_INTERNAL_ERR;
+ }
/* reading username */
in_uint16_be(c->in_s, sz);
diff --git a/sesman/sesman.ini b/sesman/sesman.ini
index 4241bd32..6235843c 100644
--- a/sesman/sesman.ini
+++ b/sesman/sesman.ini
@@ -91,3 +91,6 @@ param8=tcp
[Chansrv]
# drive redirection, defaults to xrdp_client if not set
FuseMountName=thinclient_drives
+
+[SessionVariables]
+PULSE_CONFIG=/etc/xrdp/pulse/daemon.conf
diff --git a/sesman/session.c b/sesman/session.c
index 6b49a3fb..091ce013 100644
--- a/sesman/session.c
+++ b/sesman/session.c
@@ -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, 0); /* mandatory */
- env_set_user(username, 0, display);
+ env_set_user(username, 0, display,
+ g_cfg->session_variables1, g_cfg->session_variables2);
/* executing sessvc */
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 */
{
- 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))
{
auth_set_env(data);
@@ -594,7 +597,9 @@ session_start_fork(int width, int height, int bpp, char *username,
}
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);
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)
{
- 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");
if (g_file_exist(text))