Adding bootstrap logging option to XRDP

This commit is contained in:
Alexandre Quesnel 2020-12-28 20:22:01 +00:00
parent 427ba4e7d9
commit d7587a282c
2 changed files with 28 additions and 16 deletions

View File

@ -54,6 +54,14 @@ Specify a path to a different \fIxrdp.ini\fR file. This option is intended
to be used primarily for testing or for unusual configurations.
.SH "ENVIRONMENT"
.TP
\fBXRDP_BOOT_LOG_LEVEL\fR
The log level to use when booting \fIxrdp\fR until the logging sub-system
is initialized from the \fIxrdp.ini\fR file. All boot log messages are
written to the console. The default boot log level is: WARN.
.SH "FILES"
@bindir@/xrdp
.br

View File

@ -347,19 +347,19 @@ xrdp_process_params(int argc, char **argv,
if (g_strlen(startup_params->port) < 1)
{
g_writeln("error processing params, port [%s]", startup_params->port);
LOG(LOG_LEVEL_ERROR, "error processing params, port [%s]", startup_params->port);
return 1;
}
else
{
g_writeln("--port parameter found, ini override [%s]",
LOG(LOG_LEVEL_INFO, "--port parameter found, ini override [%s]",
startup_params->port);
}
}
else if (nocase_matches(option, "-f", "--fork", NULL))
{
startup_params->fork = 1;
g_writeln("--fork parameter found, ini override");
LOG(LOG_LEVEL_INFO, "--fork parameter found, ini override");
}
else if (nocase_matches(option, "--dump-config", NULL))
{
@ -396,14 +396,14 @@ xrdp_sanity_check(void)
#if defined(B_ENDIAN)
if (!host_be)
{
g_writeln("Not a big endian machine, edit arch.h");
LOG(LOG_LEVEL_ERROR, "Not a big endian machine, edit arch.h");
return 1;
}
#endif
#if defined(L_ENDIAN)
if (host_be)
{
g_writeln("Not a little endian machine, edit arch.h");
LOG(LOG_LEVEL_ERROR, "Not a little endian machine, edit arch.h");
return 1;
}
#endif
@ -411,31 +411,31 @@ xrdp_sanity_check(void)
/* check long, int and void* sizes */
if (sizeof(int) != 4)
{
g_writeln("unusable int size, must be 4");
LOG(LOG_LEVEL_ERROR, "unusable int size, must be 4");
return 1;
}
if (sizeof(long) != sizeof(void *))
{
g_writeln("long size must match void* size");
LOG(LOG_LEVEL_ERROR, "long size must match void* size");
return 1;
}
if (sizeof(long) != 4 && sizeof(long) != 8)
{
g_writeln("unusable long size, must be 4 or 8");
LOG(LOG_LEVEL_ERROR, "unusable long size, must be 4 or 8");
return 1;
}
if (sizeof(tui64) != 8)
{
g_writeln("unusable tui64 size, must be 8");
LOG(LOG_LEVEL_ERROR, "unusable tui64 size, must be 8");
return 1;
}
if (!g_file_exist(key_file))
{
g_writeln("File %s is missing, create it using xrdp-keygen", key_file);
LOG(LOG_LEVEL_ERROR, "File %s is missing, create it using xrdp-keygen", key_file);
return 1;
}
@ -455,15 +455,20 @@ main(int argc, char **argv)
int daemon;
char text[256];
const char *pid_file = XRDP_PID_PATH "/xrdp.pid";
struct log_config *bootstrap_log_config;
int errored_argc;
g_init("xrdp");
ssl_init();
bootstrap_log_config = log_config_init_for_console(LOG_LEVEL_WARNING,
g_getenv("XRDP_BOOT_LOG_LEVEL"));
log_start_from_param(bootstrap_log_config);
log_config_free(bootstrap_log_config);
for (test = 0; test < argc; test++)
{
DEBUG(("Argument %i - %s", test, argv[test]));
LOG(LOG_LEVEL_DEBUG, "Argument %i - %s", test, argv[test]);
}
startup_params.xrdp_ini = XRDP_CFG_PATH "/xrdp.ini";
@ -539,6 +544,8 @@ main(int argc, char **argv)
g_exit(0);
}
/* end the bootstrap logging */
log_end();
/* starting logging subsystem */
error = log_start(startup_params.xrdp_ini, "xrdp",
startup_params.dump_config);
@ -605,10 +612,7 @@ main(int argc, char **argv)
g_file_close(fd);
g_file_delete(pid_file);
}
if (daemon)
{
/* if can't listen, exit with failure status */
if (xrdp_listen_test(&startup_params) != 0)
{