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-10-06 23:25:29 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2005-11-14 01:06:49 +03:00
|
|
|
* @file sig.c
|
|
|
|
* @brief signal handling functions
|
|
|
|
* @author Jay Sorg, Simone Fedele
|
2007-04-07 20:20:08 +04:00
|
|
|
*
|
2005-10-06 23:25:29 +04:00
|
|
|
*/
|
|
|
|
|
2017-03-03 07:33:23 +03:00
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
|
|
#include <config_ac.h>
|
|
|
|
#endif
|
|
|
|
|
2022-09-08 17:05:51 +03:00
|
|
|
#include "arch.h"
|
|
|
|
#include "sig.h"
|
|
|
|
|
2023-03-20 18:08:04 +03:00
|
|
|
#include "sesman_config.h"
|
2022-09-08 17:05:51 +03:00
|
|
|
#include "log.h"
|
|
|
|
#include "os_calls.h"
|
2017-01-05 00:13:20 +03:00
|
|
|
#include "sesman.h"
|
2023-03-09 18:40:56 +03:00
|
|
|
#include "session_list.h"
|
2022-09-08 17:05:51 +03:00
|
|
|
#include "string_calls.h"
|
2006-07-14 00:15:21 +04:00
|
|
|
|
2005-11-14 01:06:49 +03:00
|
|
|
/******************************************************************************/
|
2017-03-12 19:35:00 +03:00
|
|
|
void
|
2022-03-03 18:37:46 +03:00
|
|
|
sig_sesman_reload_cfg(void)
|
2005-10-06 23:25:29 +04:00
|
|
|
{
|
2012-09-20 07:51:34 +04:00
|
|
|
int error;
|
|
|
|
struct config_sesman *cfg;
|
|
|
|
|
2022-03-03 18:37:46 +03:00
|
|
|
LOG(LOG_LEVEL_INFO, "receiving SIGHUP");
|
2012-09-20 07:51:34 +04:00
|
|
|
|
2020-06-22 12:27:54 +03:00
|
|
|
if ((cfg = config_read(g_cfg->sesman_ini)) == NULL)
|
2012-09-20 07:51:34 +04:00
|
|
|
{
|
2020-11-30 03:36:20 +03:00
|
|
|
LOG(LOG_LEVEL_ERROR, "error reading config - keeping old cfg");
|
2012-09-20 07:51:34 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-03 18:37:46 +03:00
|
|
|
/* Deal with significant config changes */
|
2022-03-19 14:29:28 +03:00
|
|
|
if (g_strcmp(g_cfg->listen_port, cfg->listen_port) != 0)
|
2022-03-03 18:37:46 +03:00
|
|
|
{
|
2022-03-19 14:29:28 +03:00
|
|
|
LOG(LOG_LEVEL_INFO, "sesman listen port changed to %s",
|
|
|
|
cfg->listen_port);
|
2022-03-03 18:37:46 +03:00
|
|
|
|
|
|
|
/* We have to delete the old port before listening to the new one
|
|
|
|
* in case they overlap in scope */
|
|
|
|
sesman_delete_listening_transport();
|
2022-03-19 14:29:28 +03:00
|
|
|
if (sesman_create_listening_transport(cfg) == 0)
|
|
|
|
{
|
|
|
|
LOG(LOG_LEVEL_INFO, "Sesman now listening on %s",
|
|
|
|
g_cfg->listen_port);
|
|
|
|
}
|
2022-03-03 18:37:46 +03:00
|
|
|
}
|
2012-09-20 07:51:34 +04:00
|
|
|
|
2016-10-21 08:22:51 +03:00
|
|
|
/* free old config data */
|
|
|
|
config_free(g_cfg);
|
|
|
|
|
2016-02-14 07:41:07 +03:00
|
|
|
/* replace old config with newly read one */
|
2012-09-20 07:51:34 +04:00
|
|
|
g_cfg = cfg;
|
|
|
|
|
2022-03-03 18:37:46 +03:00
|
|
|
/* Restart logging subsystem */
|
|
|
|
error = log_start(g_cfg->sesman_ini, "xrdp-sesman", LOG_START_RESTART);
|
2012-09-20 07:51:34 +04:00
|
|
|
|
|
|
|
if (error != LOG_STARTUP_OK)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
|
|
|
|
switch (error)
|
|
|
|
{
|
|
|
|
case LOG_ERROR_MALLOC:
|
|
|
|
g_printf("error on malloc. cannot restart logging. log stops here, sorry.\n");
|
|
|
|
break;
|
|
|
|
case LOG_ERROR_FILE_OPEN:
|
|
|
|
g_printf("error reopening log file [%s]. log stops here, sorry.\n", getLogFile(buf, 255));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-30 03:36:20 +03:00
|
|
|
LOG(LOG_LEVEL_INFO, "configuration reloaded, log subsystem restarted");
|
2005-10-06 23:25:29 +04:00
|
|
|
}
|