2012-09-20 07:51:34 +04:00
|
|
|
/**
|
|
|
|
* xrdp: A Remote Desktop Protocol server.
|
|
|
|
*
|
2013-06-08 21:51:53 +04:00
|
|
|
* Copyright (C) Jay Sorg 2004-2013
|
2012-09-20 07:51:34 +04:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2005-09-25 07:30:09 +04:00
|
|
|
|
2006-05-26 00:34:32 +04:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @file config.c
|
|
|
|
* @brief User authentication code
|
|
|
|
* @author Simone Fedele @< simo [at] esseemme [dot] org @>
|
2007-03-26 01:20:20 +04:00
|
|
|
*
|
2006-05-26 00:34:32 +04:00
|
|
|
*/
|
|
|
|
|
2017-03-03 07:33:23 +03:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include <config_ac.h>
|
|
|
|
#endif
|
|
|
|
|
2005-11-19 04:37:49 +03:00
|
|
|
#include "arch.h"
|
2005-09-25 07:30:09 +04:00
|
|
|
#include "list.h"
|
|
|
|
#include "file.h"
|
2005-10-06 23:21:18 +04:00
|
|
|
#include "sesman.h"
|
2012-05-27 19:17:39 +04:00
|
|
|
#include "log.h"
|
2005-09-25 07:30:09 +04:00
|
|
|
|
2012-05-27 19:17:39 +04:00
|
|
|
|
2005-10-24 01:47:17 +04:00
|
|
|
|
2005-09-25 07:30:09 +04:00
|
|
|
/******************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-09-20 07:51:34 +04:00
|
|
|
config_read(struct config_sesman *cfg)
|
2005-09-25 07:30:09 +04:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
int fd;
|
|
|
|
struct list *sec;
|
|
|
|
struct list *param_n;
|
|
|
|
struct list *param_v;
|
|
|
|
char cfg_file[256];
|
|
|
|
|
|
|
|
g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
|
|
|
|
fd = g_file_open(cfg_file);
|
|
|
|
|
|
|
|
if (-1 == fd)
|
|
|
|
{
|
|
|
|
//if (g_cfg->log.fd >= 0)
|
|
|
|
//{
|
|
|
|
/* logging is already active */
|
|
|
|
log_message(LOG_LEVEL_ALWAYS, "error opening %s in \
|
2009-05-19 08:23:49 +04:00
|
|
|
config_read", cfg_file);
|
2012-09-20 07:51:34 +04:00
|
|
|
//}
|
|
|
|
//else
|
|
|
|
//{
|
|
|
|
g_printf("error opening %s in config_read", cfg_file);
|
|
|
|
//}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_memset(cfg, 0, sizeof(struct config_sesman));
|
|
|
|
sec = list_create();
|
|
|
|
sec->auto_free = 1;
|
|
|
|
file_read_sections(fd, sec);
|
|
|
|
param_n = list_create();
|
|
|
|
param_n->auto_free = 1;
|
|
|
|
param_v = list_create();
|
|
|
|
param_v->auto_free = 1;
|
|
|
|
|
|
|
|
/* read global config */
|
|
|
|
config_read_globals(fd, cfg, param_n, param_v);
|
|
|
|
|
2018-05-29 20:34:48 +03:00
|
|
|
/* read Xvnc/X11rdp/Xorg parameter list */
|
2012-09-20 07:51:34 +04:00
|
|
|
config_read_vnc_params(fd, cfg, param_n, param_v);
|
|
|
|
config_read_rdp_params(fd, cfg, param_n, param_v);
|
2014-03-09 04:41:37 +04:00
|
|
|
config_read_xorg_params(fd, cfg, param_n, param_v);
|
2012-09-20 07:51:34 +04:00
|
|
|
|
|
|
|
/* read security config */
|
|
|
|
config_read_security(fd, &(cfg->sec), param_n, param_v);
|
|
|
|
|
|
|
|
/* read session config */
|
|
|
|
config_read_sessions(fd, &(cfg->sess), param_n, param_v);
|
|
|
|
|
2014-05-10 03:02:19 +04:00
|
|
|
config_read_session_variables(fd, cfg, param_n, param_v);
|
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
/* cleanup */
|
|
|
|
list_delete(sec);
|
|
|
|
list_delete(param_v);
|
|
|
|
list_delete(param_n);
|
|
|
|
g_file_close(fd);
|
|
|
|
return 0;
|
2005-10-24 01:47:17 +04:00
|
|
|
}
|
|
|
|
|
2005-11-19 04:37:49 +03:00
|
|
|
/******************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-09-20 07:51:34 +04:00
|
|
|
config_read_globals(int file, struct config_sesman *cf, struct list *param_n,
|
|
|
|
struct list *param_v)
|
2005-10-24 01:47:17 +04:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
int i;
|
2018-06-15 08:10:25 +03:00
|
|
|
int length;
|
2012-09-20 07:51:34 +04:00
|
|
|
char *buf;
|
2005-10-24 01:47:17 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
list_clear(param_v);
|
|
|
|
list_clear(param_n);
|
2006-04-24 01:54:12 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
/* resetting the struct */
|
|
|
|
cf->listen_address[0] = '\0';
|
|
|
|
cf->listen_port[0] = '\0';
|
|
|
|
cf->enable_user_wm = 0;
|
|
|
|
cf->user_wm[0] = '\0';
|
2018-06-14 05:59:27 +03:00
|
|
|
cf->default_wm = 0;
|
2012-09-20 07:51:34 +04:00
|
|
|
cf->auth_file_path = 0;
|
2018-06-14 09:31:12 +03:00
|
|
|
cf->reconnect_sh = 0;
|
2005-11-19 04:37:49 +03:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
file_read_section(file, SESMAN_CFG_GLOBALS, param_n, param_v);
|
|
|
|
|
|
|
|
for (i = 0; i < param_n->count; i++)
|
2005-09-25 07:30:09 +04:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
buf = (char *)list_get_item(param_n, i);
|
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_DEFWM))
|
|
|
|
{
|
2018-06-14 05:59:27 +03:00
|
|
|
cf->default_wm = g_strdup((char *)list_get_item(param_v, i));
|
2012-09-20 07:51:34 +04:00
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(buf, SESMAN_CFG_USERWM))
|
|
|
|
{
|
|
|
|
g_strncpy(cf->user_wm, (char *)list_get_item(param_v, i), 31);
|
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(buf, SESMAN_CFG_ENABLE_USERWM))
|
|
|
|
{
|
2013-08-25 09:41:44 +04:00
|
|
|
cf->enable_user_wm = g_text2bool((char *)list_get_item(param_v, i));
|
2012-09-20 07:51:34 +04:00
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(buf, SESMAN_CFG_PORT))
|
|
|
|
{
|
|
|
|
g_strncpy(cf->listen_port, (char *)list_get_item(param_v, i), 15);
|
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(buf, SESMAN_CFG_ADDRESS))
|
|
|
|
{
|
|
|
|
g_strncpy(cf->listen_address, (char *)list_get_item(param_v, i), 31);
|
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(buf, SESMAN_CFG_AUTH_FILE_PATH))
|
|
|
|
{
|
|
|
|
cf->auth_file_path = g_strdup((char *)list_get_item(param_v, i));
|
|
|
|
}
|
2018-06-14 09:31:12 +03:00
|
|
|
else if (g_strcasecmp(buf, SESMAN_CFG_RECONNECT_SH) == 0)
|
|
|
|
{
|
|
|
|
cf->reconnect_sh = g_strdup((char *)list_get_item(param_v, i));
|
|
|
|
}
|
2005-09-25 07:30:09 +04:00
|
|
|
}
|
2012-09-20 07:51:34 +04:00
|
|
|
|
|
|
|
/* checking for missing required parameters */
|
|
|
|
if ('\0' == cf->listen_address[0])
|
2005-09-25 07:30:09 +04:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
g_strncpy(cf->listen_address, "0.0.0.0", 8);
|
2005-09-25 07:30:09 +04:00
|
|
|
}
|
2012-09-20 07:51:34 +04:00
|
|
|
|
|
|
|
if ('\0' == cf->listen_port[0])
|
2005-09-25 07:30:09 +04:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
g_strncpy(cf->listen_port, "3350", 5);
|
2005-09-25 07:30:09 +04:00
|
|
|
}
|
2012-09-20 07:51:34 +04:00
|
|
|
|
|
|
|
if ('\0' == cf->user_wm[0])
|
2007-03-26 01:20:20 +04:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
cf->enable_user_wm = 0;
|
2007-03-26 01:20:20 +04:00
|
|
|
}
|
2012-09-20 07:51:34 +04:00
|
|
|
|
2018-06-14 05:59:27 +03:00
|
|
|
if (cf->default_wm == 0)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2018-06-14 05:59:27 +03:00
|
|
|
cf->default_wm = g_strdup("startwm.sh");
|
|
|
|
}
|
|
|
|
else if (g_strlen(cf->default_wm) == 0)
|
|
|
|
{
|
|
|
|
g_free(cf->default_wm);
|
|
|
|
cf->default_wm = g_strdup("startwm.sh");
|
|
|
|
}
|
2018-06-15 08:10:25 +03:00
|
|
|
/* if default_wm doesn't begin with '/', it's a relative path to XRDP_CFG_PATH */
|
2018-06-14 05:59:27 +03:00
|
|
|
if (cf->default_wm[0] != '/')
|
|
|
|
{
|
2018-06-19 06:57:30 +03:00
|
|
|
/* sizeof operator returns string length including null terminator */
|
2019-03-28 05:42:32 +03:00
|
|
|
length = sizeof(XRDP_CFG_PATH) + g_strlen(cf->default_wm) + 1; /* '/' */
|
2018-06-15 08:10:25 +03:00
|
|
|
buf = (char *)g_malloc(length, 0);
|
2019-03-28 05:42:32 +03:00
|
|
|
g_sprintf(buf, "%s/%s", XRDP_CFG_PATH, cf->default_wm);
|
|
|
|
g_free(cf->default_wm);
|
|
|
|
cf->default_wm = g_strdup(buf);
|
2018-06-14 05:59:27 +03:00
|
|
|
g_free(buf);
|
2007-05-07 01:02:25 +04:00
|
|
|
}
|
2005-11-19 04:37:49 +03:00
|
|
|
|
2018-06-14 09:31:12 +03:00
|
|
|
if (cf->reconnect_sh == 0)
|
|
|
|
{
|
|
|
|
cf->reconnect_sh = g_strdup("reconnectwm.sh");
|
|
|
|
}
|
|
|
|
else if (g_strlen(cf->reconnect_sh) == 0)
|
|
|
|
{
|
|
|
|
g_free(cf->reconnect_sh);
|
|
|
|
cf->reconnect_sh = g_strdup("reconnectwm.sh");
|
|
|
|
}
|
2018-06-15 08:10:25 +03:00
|
|
|
/* if reconnect_sh doesn't begin with '/', it's a relative path to XRDP_CFG_PATH */
|
2018-06-14 09:31:12 +03:00
|
|
|
if (cf->reconnect_sh[0] != '/')
|
|
|
|
{
|
2018-06-19 06:57:30 +03:00
|
|
|
/* sizeof operator returns string length including null terminator */
|
2019-03-28 05:42:32 +03:00
|
|
|
length = sizeof(XRDP_CFG_PATH) + g_strlen(cf->reconnect_sh) + 1; /* '/' */
|
2018-06-15 08:10:25 +03:00
|
|
|
buf = (char *)g_malloc(length, 0);
|
2019-03-28 05:42:32 +03:00
|
|
|
g_sprintf(buf, "%s/%s", XRDP_CFG_PATH, cf->reconnect_sh);
|
|
|
|
g_free(cf->reconnect_sh);
|
|
|
|
cf->reconnect_sh = g_strdup(buf);
|
2018-06-14 09:31:12 +03:00
|
|
|
g_free(buf);
|
|
|
|
}
|
|
|
|
|
2019-03-28 05:42:32 +03:00
|
|
|
log_message(LOG_LEVEL_TRACE, "config loaded in %s at %s:%d", __func__, __FILE__, __LINE__);
|
|
|
|
log_message(LOG_LEVEL_TRACE, " listen_address = %s", cf->listen_address);
|
|
|
|
log_message(LOG_LEVEL_TRACE, " listen_port = %s", cf->listen_port);
|
|
|
|
log_message(LOG_LEVEL_TRACE, " enable_user_wm = %d", cf->enable_user_wm);
|
|
|
|
log_message(LOG_LEVEL_TRACE, " default_wm = %s", cf->default_wm);
|
|
|
|
log_message(LOG_LEVEL_TRACE, " user_wm = %s", cf->user_wm);
|
|
|
|
log_message(LOG_LEVEL_TRACE, " reconnect_sh = %s", cf->reconnect_sh);
|
|
|
|
log_message(LOG_LEVEL_TRACE, " auth_file_path = %s", cf->auth_file_path);
|
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
return 0;
|
2005-10-24 01:47:17 +04:00
|
|
|
}
|
|
|
|
|
2005-12-15 23:41:03 +03:00
|
|
|
/******************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-09-20 07:51:34 +04:00
|
|
|
config_read_security(int file, struct config_security *sc,
|
|
|
|
struct list *param_n,
|
|
|
|
struct list *param_v)
|
2005-12-15 23:41:03 +03:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
int i;
|
|
|
|
int gid;
|
|
|
|
char *buf;
|
2005-12-15 23:41:03 +03:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
list_clear(param_v);
|
|
|
|
list_clear(param_n);
|
2005-12-15 23:41:03 +03:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
/* setting defaults */
|
|
|
|
sc->allow_root = 0;
|
|
|
|
sc->login_retry = 3;
|
|
|
|
sc->ts_users_enable = 0;
|
|
|
|
sc->ts_admins_enable = 0;
|
2019-02-26 13:36:32 +03:00
|
|
|
sc->restrict_outbound_clipboard = 0;
|
2005-12-15 23:41:03 +03:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
file_read_section(file, SESMAN_CFG_SECURITY, param_n, param_v);
|
|
|
|
|
|
|
|
for (i = 0; i < param_n->count; i++)
|
2005-12-15 23:41:03 +03:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
buf = (char *)list_get_item(param_n, i);
|
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ALLOW_ROOT))
|
|
|
|
{
|
2013-08-25 09:41:44 +04:00
|
|
|
sc->allow_root = g_text2bool((char *)list_get_item(param_v, i));
|
2012-09-20 07:51:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_LOGIN_RETRY))
|
|
|
|
{
|
|
|
|
sc->login_retry = g_atoi((char *)list_get_item(param_v, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_USR_GROUP))
|
|
|
|
{
|
|
|
|
if (g_getgroup_info((char *)list_get_item(param_v, i), &gid) == 0)
|
|
|
|
{
|
|
|
|
sc->ts_users_enable = 1;
|
|
|
|
sc->ts_users = gid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ADM_GROUP))
|
|
|
|
{
|
|
|
|
if (g_getgroup_info((char *)list_get_item(param_v, i), &gid) == 0)
|
|
|
|
{
|
|
|
|
sc->ts_admins_enable = 1;
|
|
|
|
sc->ts_admins = gid;
|
|
|
|
}
|
|
|
|
}
|
2013-01-31 18:19:58 +04:00
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_ALWAYSGROUPCHECK))
|
|
|
|
{
|
2013-08-25 09:41:44 +04:00
|
|
|
sc->ts_always_group_check = g_text2bool((char *)list_get_item(param_v, i));
|
2013-06-08 21:51:53 +04:00
|
|
|
}
|
2019-02-26 13:36:32 +03:00
|
|
|
|
2019-03-08 10:42:18 +03:00
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_RESTRICT_OUTBOUND_CLIPBOARD))
|
2018-11-19 15:04:43 +03:00
|
|
|
{
|
2019-02-26 13:36:32 +03:00
|
|
|
sc->restrict_outbound_clipboard = g_text2bool((char *)list_get_item(param_v, i));
|
2018-11-19 15:04:43 +03:00
|
|
|
}
|
|
|
|
|
2005-12-15 23:41:03 +03:00
|
|
|
}
|
2012-09-20 07:51:34 +04:00
|
|
|
|
|
|
|
return 0;
|
2005-12-15 23:41:03 +03:00
|
|
|
}
|
|
|
|
|
2006-01-13 18:51:23 +03:00
|
|
|
/******************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-09-20 07:51:34 +04:00
|
|
|
config_read_sessions(int file, struct config_sessions *se, struct list *param_n,
|
|
|
|
struct list *param_v)
|
2006-01-13 18:51:23 +03:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
int i;
|
|
|
|
char *buf;
|
2006-01-13 18:51:23 +03:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
list_clear(param_v);
|
|
|
|
list_clear(param_n);
|
2006-01-13 18:51:23 +03:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
/* setting defaults */
|
|
|
|
se->x11_display_offset = 10;
|
|
|
|
se->max_sessions = 0;
|
|
|
|
se->max_idle_time = 0;
|
|
|
|
se->max_disc_time = 0;
|
|
|
|
se->kill_disconnected = 0;
|
2014-04-20 11:42:19 +04:00
|
|
|
se->policy = SESMAN_CFG_SESS_POLICY_DFLT;
|
2007-03-26 01:20:20 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
file_read_section(file, SESMAN_CFG_SESSIONS, param_n, param_v);
|
|
|
|
|
|
|
|
for (i = 0; i < param_n->count; i++)
|
2006-01-13 18:51:23 +03:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
buf = (char *)list_get_item(param_n, i);
|
|
|
|
|
2016-06-22 02:30:15 +03:00
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_X11DISPLAYOFFSET))
|
2012-09-20 07:51:34 +04:00
|
|
|
{
|
|
|
|
se->x11_display_offset = g_atoi((char *)list_get_item(param_v, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_MAX))
|
|
|
|
{
|
|
|
|
se->max_sessions = g_atoi((char *)list_get_item(param_v, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_KILL_DISC))
|
|
|
|
{
|
2013-08-25 09:41:44 +04:00
|
|
|
se->kill_disconnected = g_text2bool((char *)list_get_item(param_v, i));
|
2012-09-20 07:51:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_IDLE_LIMIT))
|
|
|
|
{
|
|
|
|
se->max_idle_time = g_atoi((char *)list_get_item(param_v, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_DISC_LIMIT))
|
|
|
|
{
|
|
|
|
se->max_disc_time = g_atoi((char *)list_get_item(param_v, i));
|
|
|
|
}
|
2014-04-20 11:42:19 +04:00
|
|
|
|
|
|
|
if (0 == g_strcasecmp(buf, SESMAN_CFG_SESS_POLICY_S))
|
|
|
|
{
|
|
|
|
char *value = (char *)list_get_item(param_v, i);
|
|
|
|
if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_DFLT_S))
|
|
|
|
{
|
|
|
|
se->policy = SESMAN_CFG_SESS_POLICY_DFLT;
|
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBD_S))
|
|
|
|
{
|
|
|
|
se->policy = SESMAN_CFG_SESS_POLICY_UBD;
|
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBI_S))
|
|
|
|
{
|
|
|
|
se->policy = SESMAN_CFG_SESS_POLICY_UBI;
|
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBC_S))
|
|
|
|
{
|
|
|
|
se->policy = SESMAN_CFG_SESS_POLICY_UBC;
|
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBDI_S))
|
|
|
|
{
|
|
|
|
se->policy = SESMAN_CFG_SESS_POLICY_UBDI;
|
|
|
|
}
|
|
|
|
else if (0 == g_strcasecmp(value, SESMAN_CFG_SESS_POLICY_UBDC_S))
|
|
|
|
{
|
|
|
|
se->policy = SESMAN_CFG_SESS_POLICY_UBDC;
|
|
|
|
}
|
|
|
|
else /* silently ignore typos */
|
|
|
|
{
|
|
|
|
se->policy = SESMAN_CFG_SESS_POLICY_DFLT;
|
|
|
|
}
|
|
|
|
}
|
2006-01-13 18:51:23 +03:00
|
|
|
}
|
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
return 0;
|
2006-01-13 18:51:23 +03:00
|
|
|
}
|
|
|
|
|
2006-09-18 08:40:43 +04:00
|
|
|
/******************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-09-20 07:51:34 +04:00
|
|
|
config_read_rdp_params(int file, struct config_sesman *cs, struct list *param_n,
|
|
|
|
struct list *param_v)
|
2006-09-18 08:40:43 +04:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
int i;
|
2006-09-18 08:40:43 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
list_clear(param_v);
|
|
|
|
list_clear(param_n);
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
cs->rdp_params = list_create();
|
2016-10-21 08:22:51 +03:00
|
|
|
cs->rdp_params->auto_free = 1;
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
file_read_section(file, SESMAN_CFG_RDP_PARAMS, param_n, param_v);
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
for (i = 0; i < param_n->count; i++)
|
|
|
|
{
|
|
|
|
list_add_item(cs->rdp_params, (long)g_strdup((char *)list_get_item(param_v, i)));
|
|
|
|
}
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
return 0;
|
2007-05-07 01:02:25 +04:00
|
|
|
}
|
|
|
|
|
2014-03-09 04:41:37 +04:00
|
|
|
/******************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2014-04-20 11:42:19 +04:00
|
|
|
config_read_xorg_params(int file, struct config_sesman *cs,
|
2014-03-09 04:41:37 +04:00
|
|
|
struct list *param_n, struct list *param_v)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
list_clear(param_v);
|
|
|
|
list_clear(param_n);
|
|
|
|
|
|
|
|
cs->xorg_params = list_create();
|
2016-10-21 08:22:51 +03:00
|
|
|
cs->xorg_params->auto_free = 1;
|
2014-03-09 04:41:37 +04:00
|
|
|
|
|
|
|
file_read_section(file, SESMAN_CFG_XORG_PARAMS, param_n, param_v);
|
|
|
|
|
|
|
|
for (i = 0; i < param_n->count; i++)
|
|
|
|
{
|
2014-04-20 11:42:19 +04:00
|
|
|
list_add_item(cs->xorg_params,
|
2014-03-09 04:41:37 +04:00
|
|
|
(long) g_strdup((char *) list_get_item(param_v, i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-05-07 01:02:25 +04:00
|
|
|
/******************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2012-09-20 07:51:34 +04:00
|
|
|
config_read_vnc_params(int file, struct config_sesman *cs, struct list *param_n,
|
|
|
|
struct list *param_v)
|
2007-05-07 01:02:25 +04:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
int i;
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
list_clear(param_v);
|
|
|
|
list_clear(param_n);
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
cs->vnc_params = list_create();
|
2016-10-21 08:22:51 +03:00
|
|
|
cs->vnc_params->auto_free = 1;
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
file_read_section(file, SESMAN_CFG_VNC_PARAMS, param_n, param_v);
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
for (i = 0; i < param_n->count; i++)
|
|
|
|
{
|
|
|
|
list_add_item(cs->vnc_params, (long)g_strdup((char *)list_get_item(param_v, i)));
|
|
|
|
}
|
2007-05-07 01:02:25 +04:00
|
|
|
|
2012-09-20 07:51:34 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2014-05-10 03:02:19 +04:00
|
|
|
|
|
|
|
/******************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
int
|
2014-05-10 03:02:19 +04:00
|
|
|
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);
|
|
|
|
|
2017-12-15 11:56:45 +03:00
|
|
|
cs->env_names = list_create();
|
|
|
|
cs->env_names->auto_free = 1;
|
|
|
|
cs->env_values = list_create();
|
|
|
|
cs->env_values->auto_free = 1;
|
2014-05-10 03:02:19 +04:00
|
|
|
|
|
|
|
file_read_section(file, SESMAN_CFG_SESSION_VARIABLES, param_n, param_v);
|
|
|
|
|
|
|
|
for (i = 0; i < param_n->count; i++)
|
|
|
|
{
|
2017-12-15 11:56:45 +03:00
|
|
|
list_add_item(cs->env_names,
|
2014-05-10 03:02:19 +04:00
|
|
|
(tintptr) g_strdup((char *) list_get_item(param_n, i)));
|
2017-12-15 11:56:45 +03:00
|
|
|
list_add_item(cs->env_values,
|
2014-05-10 03:02:19 +04:00
|
|
|
(tintptr) g_strdup((char *) list_get_item(param_v, i)));
|
|
|
|
}
|
|
|
|
|
2018-05-29 21:48:04 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
config_dump(struct config_sesman *config)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct config_sessions *se;
|
|
|
|
struct config_security *sc;
|
|
|
|
se = &(config->sess);
|
|
|
|
sc = &(config->sec);
|
|
|
|
|
|
|
|
/* Global sesman configuration */
|
|
|
|
g_writeln("Global configuration:");
|
|
|
|
g_writeln(" ListenAddress: %s", config->listen_address);
|
|
|
|
g_writeln(" ListenPort: %s", config->listen_port);
|
|
|
|
g_writeln(" EnableUserWindowManager: %d", config->enable_user_wm);
|
|
|
|
g_writeln(" UserWindowManager: %s", config->user_wm);
|
|
|
|
g_writeln(" DefaultWindowManager: %s", config->default_wm);
|
2018-06-14 09:31:12 +03:00
|
|
|
g_writeln(" ReconnectScript: %s", config->reconnect_sh);
|
2018-05-29 21:48:04 +03:00
|
|
|
g_writeln(" AuthFilePath: %s",
|
2019-02-26 09:40:10 +03:00
|
|
|
((config->auth_file_path) ? (config->auth_file_path) : ("disabled")));
|
2018-05-29 21:48:04 +03:00
|
|
|
|
|
|
|
/* Session configuration */
|
|
|
|
g_writeln("Session configuration:");
|
|
|
|
g_writeln(" MaxSessions: %d", se->max_sessions);
|
|
|
|
g_writeln(" X11DisplayOffset: %d", se->x11_display_offset);
|
|
|
|
g_writeln(" KillDisconnected: %d", se->kill_disconnected);
|
|
|
|
g_writeln(" IdleTimeLimit: %d", se->max_idle_time);
|
|
|
|
g_writeln(" DisconnectedTimeLimit: %d", se->max_disc_time);
|
|
|
|
g_writeln(" Policy: %d", se->policy);
|
|
|
|
|
|
|
|
/* Security configuration */
|
|
|
|
g_writeln("Security configuration:");
|
|
|
|
g_writeln(" AllowRootLogin: %d", sc->allow_root);
|
|
|
|
g_writeln(" MaxLoginRetry: %d", sc->login_retry);
|
|
|
|
g_writeln(" AlwaysGroupCheck: %d", sc->ts_always_group_check);
|
2019-02-26 13:36:32 +03:00
|
|
|
g_writeln(" RestrictOutboundClipboard: %d", sc->restrict_outbound_clipboard);
|
2018-05-29 21:48:04 +03:00
|
|
|
|
|
|
|
g_printf( " TSUsersGroup: ");
|
|
|
|
if (sc->ts_users_enable)
|
|
|
|
{
|
|
|
|
g_printf("%d", sc->ts_users);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_printf("(not defined)");
|
|
|
|
}
|
|
|
|
g_writeln("%s", "");
|
|
|
|
|
|
|
|
g_printf( " TSAdminsGroup: ");
|
|
|
|
if (sc->ts_admins_enable)
|
|
|
|
{
|
|
|
|
g_printf("%d", sc->ts_admins);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
g_printf("(not defined)");
|
|
|
|
}
|
|
|
|
g_writeln("%s", "");
|
|
|
|
|
2014-05-10 03:02:19 +04:00
|
|
|
|
2018-05-29 21:48:04 +03:00
|
|
|
/* Xorg */
|
|
|
|
if (config->xorg_params->count)
|
2014-05-10 03:02:19 +04:00
|
|
|
{
|
2018-05-29 21:48:04 +03:00
|
|
|
g_writeln("Xorg parameters:");
|
2014-05-10 03:02:19 +04:00
|
|
|
}
|
|
|
|
|
2018-05-29 21:48:04 +03:00
|
|
|
for (i = 0; i < config->xorg_params->count; i++)
|
|
|
|
{
|
|
|
|
g_writeln(" Parameter %02d %s",
|
2019-02-26 09:40:10 +03:00
|
|
|
i, (char *) list_get_item(config->xorg_params, i));
|
2018-05-29 21:48:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Xvnc */
|
|
|
|
if (config->vnc_params->count)
|
|
|
|
{
|
|
|
|
g_writeln("Xvnc parameters:");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < config->vnc_params->count; i++)
|
|
|
|
{
|
|
|
|
g_writeln(" Parameter %02d %s",
|
2019-02-26 09:40:10 +03:00
|
|
|
i, (char *)list_get_item(config->vnc_params, i));
|
2018-05-29 21:48:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* X11rdp */
|
|
|
|
if (config->rdp_params->count)
|
|
|
|
{
|
|
|
|
g_writeln("X11rdp parameters:");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < config->rdp_params->count; i++)
|
|
|
|
{
|
|
|
|
g_writeln(" Parameter %02d %s",
|
2019-02-26 09:40:10 +03:00
|
|
|
i, (char *)list_get_item(config->rdp_params, i));
|
2018-05-29 21:48:04 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SessionVariables */
|
|
|
|
if (config->env_names->count)
|
|
|
|
{
|
|
|
|
g_writeln("%s parameters:", SESMAN_CFG_SESSION_VARIABLES);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < config->env_names->count; i++)
|
|
|
|
{
|
|
|
|
g_writeln(" Parameter %02d %s=%s",
|
|
|
|
i, (char *) list_get_item(config->env_names, i),
|
2019-02-26 09:40:10 +03:00
|
|
|
(char *) list_get_item(config->env_values, i));
|
2018-05-29 21:48:04 +03:00
|
|
|
}
|
2014-05-10 03:02:19 +04:00
|
|
|
}
|
2016-10-21 08:22:51 +03:00
|
|
|
|
|
|
|
void
|
|
|
|
config_free(struct config_sesman *cs)
|
|
|
|
{
|
2018-06-14 05:59:27 +03:00
|
|
|
g_free(cs->default_wm);
|
2018-06-14 09:31:12 +03:00
|
|
|
g_free(cs->reconnect_sh);
|
2018-06-13 11:20:03 +03:00
|
|
|
g_free(cs->auth_file_path);
|
2016-10-21 08:22:51 +03:00
|
|
|
list_delete(cs->rdp_params);
|
|
|
|
list_delete(cs->vnc_params);
|
|
|
|
list_delete(cs->xorg_params);
|
2017-12-15 11:56:45 +03:00
|
|
|
list_delete(cs->env_names);
|
|
|
|
list_delete(cs->env_values);
|
2016-10-21 08:22:51 +03:00
|
|
|
g_free(cs);
|
|
|
|
}
|