xrdp/sesman/sig.c

98 lines
2.6 KiB
C
Raw Permalink Normal View History

/**
* xrdp: A Remote Desktop Protocol server.
*
2013-06-08 21:51:53 +04:00
* Copyright (C) Jay Sorg 2004-2013
*
* 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
/**
*
* @file sig.c
* @brief signal handling functions
* @author Jay Sorg, Simone Fedele
*
2005-10-06 23:25:29 +04:00
*/
#if defined(HAVE_CONFIG_H)
#include <config_ac.h>
#endif
#include "arch.h"
#include "sig.h"
#include "sesman_config.h"
#include "log.h"
#include "os_calls.h"
#include "sesman.h"
#include "session_list.h"
#include "string_calls.h"
2006-07-14 00:15:21 +04: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
{
int error;
struct config_sesman *cfg;
2022-03-03 18:37:46 +03:00
LOG(LOG_LEVEL_INFO, "receiving SIGHUP");
2020-06-22 12:27:54 +03:00
if ((cfg = config_read(g_cfg->sesman_ini)) == NULL)
{
LOG(LOG_LEVEL_ERROR, "error reading config - keeping old cfg");
return;
}
2022-03-03 18:37:46 +03:00
/* Deal with significant config changes */
if (g_strcmp(g_cfg->listen_port, cfg->listen_port) != 0)
2022-03-03 18:37:46 +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();
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
}
/* free old config data */
config_free(g_cfg);
2016-02-14 07:41:07 +03:00
/* replace old config with newly read one */
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);
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;
}
}
LOG(LOG_LEVEL_INFO, "configuration reloaded, log subsystem restarted");
2005-10-06 23:25:29 +04:00
}