Added -c / --config to xrdp
This commit is contained in:
parent
62befaa803
commit
ebc21fe180
@ -279,7 +279,7 @@ internalReadConfiguration(const char *inFilename, const char *applicationName)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fd = g_file_open(inFilename);
|
fd = g_file_open_ex(inFilename, 1, 0, 0, 0);
|
||||||
|
|
||||||
if (-1 == fd)
|
if (-1 == fd)
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,17 @@
|
|||||||
\fBxrdp\fR \- a Remote Desktop Protocol (RDP) server
|
\fBxrdp\fR \- a Remote Desktop Protocol (RDP) server
|
||||||
|
|
||||||
.SH "SYNTAX"
|
.SH "SYNTAX"
|
||||||
xrdp [ \-\-nodaemon | \-\-kill | \-\-help ]
|
.B xrdp
|
||||||
|
\-\-kill
|
||||||
|
.br
|
||||||
|
.B xrdp
|
||||||
|
\-\-help
|
||||||
|
.br
|
||||||
|
.B xrdp
|
||||||
|
\-\-version
|
||||||
|
.br
|
||||||
|
.B xrdp
|
||||||
|
[ \-\-nodaemon ] [ --port port ] [ --fork ] [ --config /path/to/xrdp.ini ]
|
||||||
|
|
||||||
.SH "DESCRIPTION"
|
.SH "DESCRIPTION"
|
||||||
\fBxrdp\fR is a Remote Desktop Protocol (RDP) Server.
|
\fBxrdp\fR is a Remote Desktop Protocol (RDP) Server.
|
||||||
@ -14,15 +24,18 @@ It can also be used as a VNC\->RDP bridge.
|
|||||||
|
|
||||||
.SH "OPTIONS"
|
.SH "OPTIONS"
|
||||||
.TP
|
.TP
|
||||||
\fB\-n\fR, \fB\-\-nodaemon\fR
|
|
||||||
Start \fBxrdp\fR in foreground instead of starting it as a daemon.
|
|
||||||
.TP
|
|
||||||
\fB\-k\fR, \fB\-\-kill\fR
|
\fB\-k\fR, \fB\-\-kill\fR
|
||||||
Kill running \fBxrdp\fR daemon.
|
Kill running \fBxrdp\fR daemon.
|
||||||
.TP
|
.TP
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
Output help information and exit.
|
Output help information and exit.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-v\fR, \fB\-\-version\fR
|
||||||
|
Output version information and exit.
|
||||||
|
.TP
|
||||||
|
\fB\-n\fR, \fB\-\-nodaemon\fR
|
||||||
|
Start \fBxrdp\fR in foreground instead of starting it as a daemon.
|
||||||
|
.TP
|
||||||
\fB\-p\fR, \fB\-\-port\fR
|
\fB\-p\fR, \fB\-\-port\fR
|
||||||
Specify TCP port to listen to. This overrides \fIport\fR setting in
|
Specify TCP port to listen to. This overrides \fIport\fR setting in
|
||||||
\fIxrdp.ini\fR file.
|
\fIxrdp.ini\fR file.
|
||||||
@ -31,6 +44,11 @@ Specify TCP port to listen to. This overrides \fIport\fR setting in
|
|||||||
Fork a new process on a new connection. If not enabled, use a new thread
|
Fork a new process on a new connection. If not enabled, use a new thread
|
||||||
for every connection. This overrides \fIfork\fR setting in
|
for every connection. This overrides \fIfork\fR setting in
|
||||||
\fIxrdp.ini\fR file.
|
\fIxrdp.ini\fR file.
|
||||||
|
.TP
|
||||||
|
\fB\-c\fR, \fB\-\-config\fR
|
||||||
|
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 "FILES"
|
.SH "FILES"
|
||||||
@bindir@/xrdp
|
@bindir@/xrdp
|
||||||
|
@ -37,13 +37,21 @@
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
struct xrdp_session *EXPORT_CC
|
struct xrdp_session *EXPORT_CC
|
||||||
libxrdp_init(tbus id, struct trans *trans)
|
libxrdp_init(tbus id, struct trans *trans, const char *xrdp_ini)
|
||||||
{
|
{
|
||||||
struct xrdp_session *session;
|
struct xrdp_session *session;
|
||||||
|
|
||||||
session = (struct xrdp_session *)g_malloc(sizeof(struct xrdp_session), 1);
|
session = (struct xrdp_session *)g_malloc(sizeof(struct xrdp_session), 1);
|
||||||
session->id = id;
|
session->id = id;
|
||||||
session->trans = trans;
|
session->trans = trans;
|
||||||
|
if (xrdp_ini != NULL)
|
||||||
|
{
|
||||||
|
session->xrdp_ini = g_strdup(xrdp_ini);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
session->xrdp_ini = g_strdup(XRDP_CFG_PATH "/xrdp.ini");
|
||||||
|
}
|
||||||
session->rdp = xrdp_rdp_create(session, trans);
|
session->rdp = xrdp_rdp_create(session, trans);
|
||||||
session->orders = xrdp_orders_create(session, (struct xrdp_rdp *)session->rdp);
|
session->orders = xrdp_orders_create(session, (struct xrdp_rdp *)session->rdp);
|
||||||
session->client_info = &(((struct xrdp_rdp *)session->rdp)->client_info);
|
session->client_info = &(((struct xrdp_rdp *)session->rdp)->client_info);
|
||||||
@ -62,6 +70,7 @@ libxrdp_exit(struct xrdp_session *session)
|
|||||||
|
|
||||||
xrdp_orders_delete((struct xrdp_orders *)session->orders);
|
xrdp_orders_delete((struct xrdp_orders *)session->orders);
|
||||||
xrdp_rdp_delete((struct xrdp_rdp *)session->rdp);
|
xrdp_rdp_delete((struct xrdp_rdp *)session->rdp);
|
||||||
|
g_free(session->xrdp_ini);
|
||||||
g_free(session);
|
g_free(session);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,7 @@ struct xrdp_session
|
|||||||
int in_process_data; /* inc / dec libxrdp_process_data calls */
|
int in_process_data; /* inc / dec libxrdp_process_data calls */
|
||||||
|
|
||||||
struct source_info si;
|
struct source_info si;
|
||||||
|
char *xrdp_ini; /* path to xrdp.ini */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct xrdp_drdynvc_procs
|
struct xrdp_drdynvc_procs
|
||||||
@ -85,8 +86,16 @@ struct xrdp_drdynvc_procs
|
|||||||
int (*data)(intptr_t id, int chan_id, char *data, int bytes);
|
int (*data)(intptr_t id, int chan_id, char *data, int bytes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/***
|
||||||
|
* Initialise the XRDP library
|
||||||
|
*
|
||||||
|
* @param id Channel ID (xrdp_process* as integer type)
|
||||||
|
* @param trans Transport object to use for this instance
|
||||||
|
* @param xrdp_ini Path to xrdp.ini config file, or NULL for default
|
||||||
|
* @return an allocated xrdp_session object
|
||||||
|
*/
|
||||||
struct xrdp_session *
|
struct xrdp_session *
|
||||||
libxrdp_init(tbus id, struct trans *trans);
|
libxrdp_init(tbus id, struct trans *trans, const char *xrdp_ini);
|
||||||
int
|
int
|
||||||
libxrdp_exit(struct xrdp_session *session);
|
libxrdp_exit(struct xrdp_session *session);
|
||||||
int
|
int
|
||||||
|
@ -42,28 +42,24 @@
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
static int
|
static int
|
||||||
xrdp_rdp_read_config(struct xrdp_client_info *client_info)
|
xrdp_rdp_read_config(const char *xrdp_ini, struct xrdp_client_info *client_info)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
struct list *items = (struct list *)NULL;
|
struct list *items = (struct list *)NULL;
|
||||||
struct list *values = (struct list *)NULL;
|
struct list *values = (struct list *)NULL;
|
||||||
char *item = NULL;
|
char *item = NULL;
|
||||||
char *value = NULL;
|
char *value = NULL;
|
||||||
char cfg_file[256];
|
|
||||||
int pos;
|
int pos;
|
||||||
char *tmp = NULL;
|
char *tmp = NULL;
|
||||||
int tmp_length = 0;
|
int tmp_length = 0;
|
||||||
|
|
||||||
/* initialize (zero out) local variables: */
|
/* initialize (zero out) local variables: */
|
||||||
g_memset(cfg_file, 0, sizeof(char) * 256);
|
|
||||||
|
|
||||||
items = list_create();
|
items = list_create();
|
||||||
items->auto_free = 1;
|
items->auto_free = 1;
|
||||||
values = list_create();
|
values = list_create();
|
||||||
values->auto_free = 1;
|
values->auto_free = 1;
|
||||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
DEBUG(("xrdp_ini %s", xrdp_ini));
|
||||||
DEBUG(("cfg_file %s", cfg_file));
|
file_by_name_read_section(xrdp_ini, "globals", items, values);
|
||||||
file_by_name_read_section(cfg_file, "globals", items, values);
|
|
||||||
|
|
||||||
for (index = 0; index < items->count; index++)
|
for (index = 0; index < items->count; index++)
|
||||||
{
|
{
|
||||||
@ -358,7 +354,7 @@ xrdp_rdp_create(struct xrdp_session *session, struct trans *trans)
|
|||||||
self->session = session;
|
self->session = session;
|
||||||
self->share_id = 66538;
|
self->share_id = 66538;
|
||||||
/* read ini settings */
|
/* read ini settings */
|
||||||
xrdp_rdp_read_config(&self->client_info);
|
xrdp_rdp_read_config(session->xrdp_ini, &self->client_info);
|
||||||
/* create sec layer */
|
/* create sec layer */
|
||||||
self->sec_layer = xrdp_sec_create(self, trans);
|
self->sec_layer = xrdp_sec_create(self, trans);
|
||||||
/* default 8 bit v1 color bitmap cache entries and size */
|
/* default 8 bit v1 color bitmap cache entries and size */
|
||||||
|
148
xrdp/xrdp.c
148
xrdp/xrdp.c
@ -22,6 +22,8 @@
|
|||||||
#include <config_ac.h>
|
#include <config_ac.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "xrdp.h"
|
#include "xrdp.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "xrdp_configure_options.h"
|
#include "xrdp_configure_options.h"
|
||||||
@ -47,12 +49,12 @@ static long g_sync_param2 = 0;
|
|||||||
static long (*g_sync_func)(long param1, long param2);
|
static long (*g_sync_func)(long param1, long param2);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void
|
static void
|
||||||
print_version(void)
|
print_version(void)
|
||||||
{
|
{
|
||||||
g_writeln("xrdp %s", PACKAGE_VERSION);
|
g_writeln("xrdp %s", PACKAGE_VERSION);
|
||||||
g_writeln(" A Remote Desktop Protocol Server.");
|
g_writeln(" A Remote Desktop Protocol Server.");
|
||||||
g_writeln(" Copyright (C) 2004-2018 Jay Sorg, "
|
g_writeln(" Copyright (C) 2004-2020 Jay Sorg, "
|
||||||
"Neutrino Labs, and all contributors.");
|
"Neutrino Labs, and all contributors.");
|
||||||
g_writeln(" See https://github.com/neutrinolabs/xrdp for more information.");
|
g_writeln(" See https://github.com/neutrinolabs/xrdp for more information.");
|
||||||
g_writeln("%s", "");
|
g_writeln("%s", "");
|
||||||
@ -67,15 +69,17 @@ print_version(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void
|
static void
|
||||||
print_help(void)
|
print_help(void)
|
||||||
{
|
{
|
||||||
g_writeln("Usage: xrdp [options]");
|
g_writeln("Usage: xrdp [options]");
|
||||||
g_writeln(" -h, --help show help");
|
|
||||||
g_writeln(" -n, --nodaemon don't fork into background");
|
|
||||||
g_writeln(" -k, --kill shut down xrdp");
|
g_writeln(" -k, --kill shut down xrdp");
|
||||||
|
g_writeln(" -h, --help show help");
|
||||||
|
g_writeln(" -v, --version show version");
|
||||||
|
g_writeln(" -n, --nodaemon don't fork into background");
|
||||||
g_writeln(" -p, --port tcp listen port");
|
g_writeln(" -p, --port tcp listen port");
|
||||||
g_writeln(" -f, --fork fork on new connection");
|
g_writeln(" -f, --fork fork on new connection");
|
||||||
|
g_writeln(" -c, --config Specify new path to xrdp.ini");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@ -137,7 +141,7 @@ g_xrdp_sync(long (*sync_func)(long param1, long param2), long sync_param1,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void
|
static void
|
||||||
xrdp_shutdown(int sig)
|
xrdp_shutdown(int sig)
|
||||||
{
|
{
|
||||||
tbus threadid;
|
tbus threadid;
|
||||||
@ -153,7 +157,7 @@ xrdp_shutdown(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void
|
static void
|
||||||
xrdp_child(int sig)
|
xrdp_child(int sig)
|
||||||
{
|
{
|
||||||
int safety;
|
int safety;
|
||||||
@ -164,7 +168,7 @@ xrdp_child(int sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void
|
static void
|
||||||
xrdp_hang_up(int sig)
|
xrdp_hang_up(int sig)
|
||||||
{
|
{
|
||||||
log_message(LOG_LEVEL_INFO, "caught SIGHUP, noop...");
|
log_message(LOG_LEVEL_INFO, "caught SIGHUP, noop...");
|
||||||
@ -225,7 +229,7 @@ g_get_sync_event(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
void
|
static void
|
||||||
pipe_sig(int sig_num)
|
pipe_sig(int sig_num)
|
||||||
{
|
{
|
||||||
/* do nothing */
|
/* do nothing */
|
||||||
@ -256,70 +260,89 @@ g_process_waiting_function(void)
|
|||||||
tc_mutex_unlock(g_sync_mutex);
|
tc_mutex_unlock(g_sync_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/**
|
||||||
|
* @brief looks for a case-insensitive match of a string in a list
|
||||||
|
* @param candidate String to match
|
||||||
|
* @param ... NULL-terminated list of strings to compare the candidate with
|
||||||
|
* @return !=0 if the candidate is found in the list
|
||||||
|
*/
|
||||||
|
static int nocase_matches(const char *candidate, ...)
|
||||||
|
{
|
||||||
|
va_list vl;
|
||||||
|
const char *member;
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
va_start(vl, candidate);
|
||||||
|
while ((member = va_arg(vl, const char *)) != NULL)
|
||||||
|
{
|
||||||
|
if (g_strcasecmp(candidate, member) == 0)
|
||||||
|
{
|
||||||
|
result = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
va_end(vl);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @brief Command line argument parser
|
* @brief Command line argument parser
|
||||||
* @param number of command line arguments
|
* @param number of command line arguments
|
||||||
* @param pointer array of commandline arguments
|
* @param pointer array of commandline arguments
|
||||||
|
* @param [out] Returned startup parameters
|
||||||
* @return 0 on success, n on nth argument is unknown
|
* @return 0 on success, n on nth argument is unknown
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
static int
|
||||||
xrdp_process_params(int argc, char **argv,
|
xrdp_process_params(int argc, char **argv,
|
||||||
struct xrdp_startup_params *startup_params)
|
struct xrdp_startup_params *startup_params)
|
||||||
{
|
{
|
||||||
int index;
|
int index;
|
||||||
char option[128];
|
const char *option;
|
||||||
char value[128];
|
const char *value;
|
||||||
|
|
||||||
index = 1;
|
index = 1;
|
||||||
|
|
||||||
while (index < argc)
|
while (index < argc)
|
||||||
{
|
{
|
||||||
g_strncpy(option, argv[index], 127);
|
option = argv[index];
|
||||||
|
|
||||||
if (index + 1 < argc)
|
if (index + 1 < argc)
|
||||||
{
|
{
|
||||||
g_strncpy(value, argv[index + 1], 127);
|
value = argv[index + 1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
value[0] = 0;
|
value = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((g_strncasecmp(option, "-help", 255)) == 0 ||
|
if (nocase_matches(option, "-help", "--help", "-h", NULL))
|
||||||
(g_strncasecmp(option, "--help", 255)) == 0 ||
|
|
||||||
(g_strncasecmp(option, "-h", 255)) == 0)
|
|
||||||
{
|
{
|
||||||
startup_params->help = 1;
|
startup_params->help = 1;
|
||||||
}
|
}
|
||||||
else if ((g_strncasecmp(option, "-kill", 255) == 0) ||
|
else if (nocase_matches(option, "-kill", "--kill", "-k", NULL))
|
||||||
(g_strncasecmp(option, "--kill", 255) == 0) ||
|
|
||||||
(g_strncasecmp(option, "-k", 255) == 0))
|
|
||||||
{
|
{
|
||||||
startup_params->kill = 1;
|
startup_params->kill = 1;
|
||||||
}
|
}
|
||||||
else if ((g_strncasecmp(option, "-nodaemon", 255) == 0) ||
|
else if (nocase_matches(option, "-nodaemon", "--nodaemon", "-n",
|
||||||
(g_strncasecmp(option, "--nodaemon", 255) == 0) ||
|
"-nd", "--nd", "-ns", "--ns", NULL))
|
||||||
(g_strncasecmp(option, "-n", 255) == 0) ||
|
|
||||||
(g_strncasecmp(option, "-nd", 255) == 0) ||
|
|
||||||
(g_strncasecmp(option, "--nd", 255) == 0) ||
|
|
||||||
(g_strncasecmp(option, "-ns", 255) == 0) ||
|
|
||||||
(g_strncasecmp(option, "--ns", 255) == 0))
|
|
||||||
{
|
{
|
||||||
startup_params->no_daemon = 1;
|
startup_params->no_daemon = 1;
|
||||||
}
|
}
|
||||||
else if ((g_strncasecmp(option, "-v", 255) == 0) ||
|
else if (nocase_matches(option, "-v", "--version", NULL))
|
||||||
(g_strncasecmp(option, "--version", 255) == 0))
|
|
||||||
{
|
{
|
||||||
startup_params->version = 1;
|
startup_params->version = 1;
|
||||||
}
|
}
|
||||||
else if ((g_strncasecmp(option, "-p", 255) == 0) ||
|
else if (nocase_matches(option, "-p", "--port", NULL))
|
||||||
(g_strncasecmp(option, "--port", 255) == 0))
|
|
||||||
{
|
{
|
||||||
index++;
|
index++;
|
||||||
g_strncpy(startup_params->port, value, 127);
|
g_strncpy(startup_params->port, value,
|
||||||
|
sizeof(startup_params->port) - 1);
|
||||||
|
|
||||||
if (g_strlen(startup_params->port) < 1)
|
if (g_strlen(startup_params->port) < 1)
|
||||||
{
|
{
|
||||||
@ -332,12 +355,16 @@ xrdp_process_params(int argc, char **argv,
|
|||||||
startup_params->port);
|
startup_params->port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((g_strncasecmp(option, "-f", 255) == 0) ||
|
else if (nocase_matches(option, "-f", "--fork", NULL))
|
||||||
(g_strncasecmp(option, "--fork", 255) == 0))
|
|
||||||
{
|
{
|
||||||
startup_params->fork = 1;
|
startup_params->fork = 1;
|
||||||
g_writeln("--fork parameter found, ini override");
|
g_writeln("--fork parameter found, ini override");
|
||||||
}
|
}
|
||||||
|
else if (nocase_matches(option, "-c", "--config", NULL))
|
||||||
|
{
|
||||||
|
index++;
|
||||||
|
startup_params->xrdp_ini = value;
|
||||||
|
}
|
||||||
else /* unknown option */
|
else /* unknown option */
|
||||||
{
|
{
|
||||||
return index;
|
return index;
|
||||||
@ -351,12 +378,12 @@ xrdp_process_params(int argc, char **argv,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Basic sanity checks before any forking */
|
/* Basic sanity checks before any forking */
|
||||||
int
|
static int
|
||||||
xrdp_sanity_check(void)
|
xrdp_sanity_check(void)
|
||||||
{
|
{
|
||||||
int intval = 1;
|
int intval = 1;
|
||||||
int host_be;
|
int host_be;
|
||||||
char key_file[256];
|
const char *key_file = XRDP_CFG_PATH "/rsakeys.ini";
|
||||||
|
|
||||||
/* check compiled endian with actual endian */
|
/* check compiled endian with actual endian */
|
||||||
host_be = !((int)(*(unsigned char *)(&intval)));
|
host_be = !((int)(*(unsigned char *)(&intval)));
|
||||||
@ -401,7 +428,6 @@ xrdp_sanity_check(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_snprintf(key_file, 255, "%s/rsakeys.ini", XRDP_CFG_PATH);
|
|
||||||
if (!g_file_exist(key_file))
|
if (!g_file_exist(key_file))
|
||||||
{
|
{
|
||||||
g_writeln("File %s is missing, create it using xrdp-keygen", key_file);
|
g_writeln("File %s is missing, create it using xrdp-keygen", key_file);
|
||||||
@ -417,14 +443,14 @@ main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int exit_status = 0;
|
int exit_status = 0;
|
||||||
int test;
|
int test;
|
||||||
char cfg_file[256];
|
|
||||||
enum logReturns error;
|
enum logReturns error;
|
||||||
struct xrdp_startup_params *startup_params;
|
struct xrdp_startup_params startup_params = {0};
|
||||||
int pid;
|
int pid;
|
||||||
int fd;
|
int fd;
|
||||||
int no_daemon;
|
int daemon;
|
||||||
char text[256];
|
char text[256];
|
||||||
char pid_file[256];
|
const char *pid_file = XRDP_PID_PATH "/xrdp.pid";
|
||||||
|
|
||||||
int errored_argc;
|
int errored_argc;
|
||||||
|
|
||||||
g_init("xrdp");
|
g_init("xrdp");
|
||||||
@ -435,12 +461,9 @@ main(int argc, char **argv)
|
|||||||
DEBUG(("Argument %i - %s", test, argv[test]));
|
DEBUG(("Argument %i - %s", test, argv[test]));
|
||||||
}
|
}
|
||||||
|
|
||||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
startup_params.xrdp_ini = XRDP_CFG_PATH "/xrdp.ini";
|
||||||
|
|
||||||
startup_params = (struct xrdp_startup_params *)
|
errored_argc = xrdp_process_params(argc, argv, &startup_params);
|
||||||
g_malloc(sizeof(struct xrdp_startup_params), 1);
|
|
||||||
|
|
||||||
errored_argc = xrdp_process_params(argc, argv, startup_params);
|
|
||||||
if (errored_argc > 0)
|
if (errored_argc > 0)
|
||||||
{
|
{
|
||||||
print_version();
|
print_version();
|
||||||
@ -453,10 +476,7 @@ main(int argc, char **argv)
|
|||||||
g_exit(1);
|
g_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_snprintf(pid_file, 255, "%s/xrdp.pid", XRDP_PID_PATH);
|
if (startup_params.help)
|
||||||
no_daemon = 0;
|
|
||||||
|
|
||||||
if (startup_params->help)
|
|
||||||
{
|
{
|
||||||
print_version();
|
print_version();
|
||||||
g_writeln("%s", "");
|
g_writeln("%s", "");
|
||||||
@ -466,7 +486,7 @@ main(int argc, char **argv)
|
|||||||
g_exit(0);
|
g_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startup_params->version)
|
if (startup_params.version)
|
||||||
{
|
{
|
||||||
print_version();
|
print_version();
|
||||||
g_deinit();
|
g_deinit();
|
||||||
@ -480,7 +500,7 @@ main(int argc, char **argv)
|
|||||||
g_exit(1);
|
g_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startup_params->kill)
|
if (startup_params.kill)
|
||||||
{
|
{
|
||||||
g_writeln("stopping xrdp");
|
g_writeln("stopping xrdp");
|
||||||
/* read the xrdp.pid file */
|
/* read the xrdp.pid file */
|
||||||
@ -515,7 +535,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* starting logging subsystem */
|
/* starting logging subsystem */
|
||||||
error = log_start(cfg_file, "xrdp");
|
error = log_start(startup_params.xrdp_ini, "xrdp");
|
||||||
|
|
||||||
if (error != LOG_STARTUP_OK)
|
if (error != LOG_STARTUP_OK)
|
||||||
{
|
{
|
||||||
@ -528,6 +548,10 @@ main(int argc, char **argv)
|
|||||||
g_writeln("error opening log file [%s]. quitting.",
|
g_writeln("error opening log file [%s]. quitting.",
|
||||||
getLogFile(text, 255));
|
getLogFile(text, 255));
|
||||||
break;
|
break;
|
||||||
|
case LOG_ERROR_NO_CFG:
|
||||||
|
g_writeln("config file %s unreadable or missing",
|
||||||
|
startup_params.xrdp_ini);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
g_writeln("log_start error");
|
g_writeln("log_start error");
|
||||||
break;
|
break;
|
||||||
@ -547,13 +571,10 @@ main(int argc, char **argv)
|
|||||||
g_exit(0);
|
g_exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startup_params->no_daemon)
|
daemon = !startup_params.no_daemon;
|
||||||
{
|
|
||||||
no_daemon = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!no_daemon)
|
if (daemon)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* make sure containing directory exists */
|
/* make sure containing directory exists */
|
||||||
@ -580,10 +601,10 @@ main(int argc, char **argv)
|
|||||||
g_file_delete(pid_file);
|
g_file_delete(pid_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!no_daemon)
|
if (daemon)
|
||||||
{
|
{
|
||||||
/* if can't listen, exit with failure status */
|
/* if can't listen, exit with failure status */
|
||||||
if (xrdp_listen_test(startup_params) != 0)
|
if (xrdp_listen_test(&startup_params) != 0)
|
||||||
{
|
{
|
||||||
log_message(LOG_LEVEL_ERROR, "Failed to start xrdp daemon, "
|
log_message(LOG_LEVEL_ERROR, "Failed to start xrdp daemon, "
|
||||||
"possibly address already in use.");
|
"possibly address already in use.");
|
||||||
@ -675,7 +696,7 @@ main(int argc, char **argv)
|
|||||||
g_writeln("error creating g_sync_event");
|
g_writeln("error creating g_sync_event");
|
||||||
}
|
}
|
||||||
|
|
||||||
g_listen->startup_params = startup_params;
|
g_listen->startup_params = &startup_params;
|
||||||
exit_status = xrdp_listen_main_loop(g_listen);
|
exit_status = xrdp_listen_main_loop(g_listen);
|
||||||
xrdp_listen_delete(g_listen);
|
xrdp_listen_delete(g_listen);
|
||||||
tc_mutex_delete(g_sync_mutex);
|
tc_mutex_delete(g_sync_mutex);
|
||||||
@ -684,13 +705,12 @@ main(int argc, char **argv)
|
|||||||
g_delete_wait_obj(g_sync_event);
|
g_delete_wait_obj(g_sync_event);
|
||||||
|
|
||||||
/* only main process should delete pid file */
|
/* only main process should delete pid file */
|
||||||
if ((!no_daemon) && (pid == g_getpid()))
|
if (daemon && (pid == g_getpid()))
|
||||||
{
|
{
|
||||||
/* delete the xrdp.pid file */
|
/* delete the xrdp.pid file */
|
||||||
g_file_delete(pid_file);
|
g_file_delete(pid_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(startup_params);
|
|
||||||
log_end();
|
log_end();
|
||||||
g_deinit();
|
g_deinit();
|
||||||
|
|
||||||
|
10
xrdp/xrdp.h
10
xrdp/xrdp.h
@ -40,6 +40,8 @@ long
|
|||||||
g_xrdp_sync(long (*sync_func)(long param1, long param2), long sync_param1,
|
g_xrdp_sync(long (*sync_func)(long param1, long param2), long sync_param1,
|
||||||
long sync_param2);
|
long sync_param2);
|
||||||
int
|
int
|
||||||
|
xrdp_child_fork(void);
|
||||||
|
int
|
||||||
g_is_term(void);
|
g_is_term(void);
|
||||||
void
|
void
|
||||||
g_set_term(int in_val);
|
g_set_term(int in_val);
|
||||||
@ -49,10 +51,6 @@ tbus
|
|||||||
g_get_sync_event(void);
|
g_get_sync_event(void);
|
||||||
void
|
void
|
||||||
g_process_waiting_function(void);
|
g_process_waiting_function(void);
|
||||||
void
|
|
||||||
print_version(void);
|
|
||||||
void
|
|
||||||
print_help(void);
|
|
||||||
|
|
||||||
/* xrdp_cache.c */
|
/* xrdp_cache.c */
|
||||||
struct xrdp_cache*
|
struct xrdp_cache*
|
||||||
@ -359,7 +357,7 @@ get_keymaps(int keylayout, struct xrdp_keymap* keymap);
|
|||||||
int
|
int
|
||||||
xrdp_login_wnd_create(struct xrdp_wm* self);
|
xrdp_login_wnd_create(struct xrdp_wm* self);
|
||||||
int
|
int
|
||||||
load_xrdp_config(struct xrdp_config *config, int bpp);
|
load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp);
|
||||||
|
|
||||||
/* xrdp_bitmap_compress.c */
|
/* xrdp_bitmap_compress.c */
|
||||||
int
|
int
|
||||||
@ -435,8 +433,6 @@ server_msg(struct xrdp_mod* mod, char* msg, int code);
|
|||||||
int
|
int
|
||||||
server_is_term(struct xrdp_mod* mod);
|
server_is_term(struct xrdp_mod* mod);
|
||||||
int
|
int
|
||||||
xrdp_child_fork(void);
|
|
||||||
int
|
|
||||||
server_set_clip(struct xrdp_mod* mod, int x, int y, int cx, int cy);
|
server_set_clip(struct xrdp_mod* mod, int x, int y, int cx, int cy);
|
||||||
int
|
int
|
||||||
server_reset_clip(struct xrdp_mod* mod);
|
server_reset_clip(struct xrdp_mod* mod);
|
||||||
|
@ -164,14 +164,12 @@ xrdp_listen_get_startup_params(struct xrdp_listen *self)
|
|||||||
char *val;
|
char *val;
|
||||||
struct list *names;
|
struct list *names;
|
||||||
struct list *values;
|
struct list *values;
|
||||||
char cfg_file[256];
|
|
||||||
struct xrdp_startup_params *startup_params;
|
struct xrdp_startup_params *startup_params;
|
||||||
|
|
||||||
startup_params = self->startup_params;
|
startup_params = self->startup_params;
|
||||||
port_override = startup_params->port[0] != 0;
|
port_override = startup_params->port[0] != 0;
|
||||||
fork_override = startup_params->fork;
|
fork_override = startup_params->fork;
|
||||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
fd = g_file_open(startup_params->xrdp_ini);
|
||||||
fd = g_file_open(cfg_file);
|
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
{
|
{
|
||||||
names = list_create();
|
names = list_create();
|
||||||
|
@ -559,8 +559,8 @@ xrdp_wm_login_fill_in_combo(struct xrdp_wm *self, struct xrdp_bitmap *b)
|
|||||||
char *q;
|
char *q;
|
||||||
char *r;
|
char *r;
|
||||||
char name[256];
|
char name[256];
|
||||||
char cfg_file[256];
|
|
||||||
struct xrdp_mod_data *mod_data;
|
struct xrdp_mod_data *mod_data;
|
||||||
|
const char *xrdp_ini = self->session->xrdp_ini;
|
||||||
|
|
||||||
sections = list_create();
|
sections = list_create();
|
||||||
sections->auto_free = 1;
|
sections->auto_free = 1;
|
||||||
@ -568,12 +568,12 @@ xrdp_wm_login_fill_in_combo(struct xrdp_wm *self, struct xrdp_bitmap *b)
|
|||||||
section_names->auto_free = 1;
|
section_names->auto_free = 1;
|
||||||
section_values = list_create();
|
section_values = list_create();
|
||||||
section_values->auto_free = 1;
|
section_values->auto_free = 1;
|
||||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
fd = g_file_open(xrdp_ini);
|
||||||
fd = g_file_open(cfg_file); /* xrdp.ini */
|
|
||||||
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
log_message(LOG_LEVEL_ERROR, "Could not read xrdp ini file %s", cfg_file);
|
log_message(LOG_LEVEL_ERROR, "Could not read xrdp ini file %s",
|
||||||
|
xrdp_ini);
|
||||||
list_delete(sections);
|
list_delete(sections);
|
||||||
list_delete(section_names);
|
list_delete(section_names);
|
||||||
list_delete(section_values);
|
list_delete(section_values);
|
||||||
@ -829,10 +829,14 @@ xrdp_login_wnd_create(struct xrdp_wm *self)
|
|||||||
/**
|
/**
|
||||||
* Load configuration from xrdp.ini file
|
* Load configuration from xrdp.ini file
|
||||||
*
|
*
|
||||||
|
* @param config XRDP configuration to initialise
|
||||||
|
* @param xrdp_ini Path to xrdp.ini
|
||||||
|
* @param bpp bits-per-pixel for this connection
|
||||||
|
*
|
||||||
* @return 0 on success, -1 on failure
|
* @return 0 on success, -1 on failure
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
int
|
int
|
||||||
load_xrdp_config(struct xrdp_config *config, int bpp)
|
load_xrdp_config(struct xrdp_config *config, const char *xrdp_ini, int bpp)
|
||||||
{
|
{
|
||||||
struct xrdp_cfg_globals *globals;
|
struct xrdp_cfg_globals *globals;
|
||||||
|
|
||||||
@ -841,7 +845,6 @@ load_xrdp_config(struct xrdp_config *config, int bpp)
|
|||||||
|
|
||||||
char *n;
|
char *n;
|
||||||
char *v;
|
char *v;
|
||||||
char buf[256];
|
|
||||||
int fd;
|
int fd;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -873,11 +876,10 @@ load_xrdp_config(struct xrdp_config *config, int bpp)
|
|||||||
globals->ls_btn_cancel_height = 30;
|
globals->ls_btn_cancel_height = 30;
|
||||||
|
|
||||||
/* open xrdp.ini file */
|
/* open xrdp.ini file */
|
||||||
g_snprintf(buf, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
if ((fd = g_file_open(xrdp_ini)) < 0)
|
||||||
if ((fd = g_file_open(buf)) < 0)
|
|
||||||
{
|
{
|
||||||
log_message(LOG_LEVEL_ERROR,"load_config: Could not read "
|
log_message(LOG_LEVEL_ERROR,"load_config: Could not read "
|
||||||
"xrdp.ini file %s", buf);
|
"xrdp.ini file %s", xrdp_ini);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -893,7 +895,7 @@ load_xrdp_config(struct xrdp_config *config, int bpp)
|
|||||||
list_delete(values);
|
list_delete(values);
|
||||||
g_file_close(fd);
|
g_file_close(fd);
|
||||||
log_message(LOG_LEVEL_ERROR,"load_config: Could not read globals "
|
log_message(LOG_LEVEL_ERROR,"load_config: Could not read globals "
|
||||||
"section from xrdp.ini file %s", buf);
|
"section from xrdp.ini file %s", xrdp_ini);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,8 @@ xrdp_process_main_loop(struct xrdp_process *self)
|
|||||||
self->server_trans->trans_data_in = xrdp_process_data_in;
|
self->server_trans->trans_data_in = xrdp_process_data_in;
|
||||||
self->server_trans->callback_data = self;
|
self->server_trans->callback_data = self;
|
||||||
init_stream(self->server_trans->in_s, 8192 * 4);
|
init_stream(self->server_trans->in_s, 8192 * 4);
|
||||||
self->session = libxrdp_init((tbus)self, self->server_trans);
|
self->session = libxrdp_init((tbus)self, self->server_trans,
|
||||||
|
self->lis_layer->startup_params->xrdp_ini);
|
||||||
self->server_trans->si = &(self->session->si);
|
self->server_trans->si = &(self->session->si);
|
||||||
self->server_trans->my_source = XRDP_SOURCE_CLIENT;
|
self->server_trans->my_source = XRDP_SOURCE_CLIENT;
|
||||||
/* this callback function is in xrdp_wm.c */
|
/* this callback function is in xrdp_wm.c */
|
||||||
|
@ -528,6 +528,8 @@ struct xrdp_mod_data
|
|||||||
|
|
||||||
struct xrdp_startup_params
|
struct xrdp_startup_params
|
||||||
{
|
{
|
||||||
|
/* xrdp_ini is not malloc'd and has at least the same lifetime as main() */
|
||||||
|
const char *xrdp_ini;
|
||||||
char port[1024];
|
char port[1024];
|
||||||
int kill;
|
int kill;
|
||||||
int no_daemon;
|
int no_daemon;
|
||||||
|
@ -396,7 +396,6 @@ xrdp_wm_load_static_colors_plus(struct xrdp_wm *self, char *autorun_name)
|
|||||||
char *val;
|
char *val;
|
||||||
struct list *names;
|
struct list *names;
|
||||||
struct list *values;
|
struct list *values;
|
||||||
char cfg_file[256];
|
|
||||||
|
|
||||||
if (autorun_name != 0)
|
if (autorun_name != 0)
|
||||||
{
|
{
|
||||||
@ -415,8 +414,7 @@ xrdp_wm_load_static_colors_plus(struct xrdp_wm *self, char *autorun_name)
|
|||||||
self->background = HCOLOR(self->screen->bpp, 0x000000);
|
self->background = HCOLOR(self->screen->bpp, 0x000000);
|
||||||
|
|
||||||
/* now load them from the globals in xrdp.ini if defined */
|
/* now load them from the globals in xrdp.ini if defined */
|
||||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
fd = g_file_open(self->session->xrdp_ini);
|
||||||
fd = g_file_open(cfg_file);
|
|
||||||
|
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
@ -507,7 +505,7 @@ xrdp_wm_load_static_colors_plus(struct xrdp_wm *self, char *autorun_name)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_message(LOG_LEVEL_ERROR,"xrdp_wm_load_static_colors: Could not read xrdp.ini file %s", cfg_file);
|
log_message(LOG_LEVEL_ERROR,"xrdp_wm_load_static_colors: Could not read xrdp.ini file %s", self->session->xrdp_ini);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self->screen->bpp == 8)
|
if (self->screen->bpp == 8)
|
||||||
@ -569,20 +567,20 @@ xrdp_wm_init(struct xrdp_wm *self)
|
|||||||
char param[256];
|
char param[256];
|
||||||
char default_section_name[256];
|
char default_section_name[256];
|
||||||
char section_name[256];
|
char section_name[256];
|
||||||
char cfg_file[256];
|
|
||||||
char autorun_name[256];
|
char autorun_name[256];
|
||||||
|
|
||||||
g_writeln("in xrdp_wm_init: ");
|
g_writeln("in xrdp_wm_init: ");
|
||||||
|
|
||||||
load_xrdp_config(self->xrdp_config, self->screen->bpp);
|
load_xrdp_config(self->xrdp_config, self->session->xrdp_ini,
|
||||||
|
self->screen->bpp);
|
||||||
|
|
||||||
/* global channels allow */
|
/* global channels allow */
|
||||||
names = list_create();
|
names = list_create();
|
||||||
names->auto_free = 1;
|
names->auto_free = 1;
|
||||||
values = list_create();
|
values = list_create();
|
||||||
values->auto_free = 1;
|
values->auto_free = 1;
|
||||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
if (file_by_name_read_section(self->session->xrdp_ini,
|
||||||
if (file_by_name_read_section(cfg_file, "Channels", names, values) == 0)
|
"Channels", names, values) == 0)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
int ii;
|
int ii;
|
||||||
@ -649,8 +647,7 @@ xrdp_wm_init(struct xrdp_wm *self)
|
|||||||
* NOTE: this should eventually be accessed from self->xrdp_config
|
* NOTE: this should eventually be accessed from self->xrdp_config
|
||||||
*/
|
*/
|
||||||
|
|
||||||
g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
|
fd = g_file_open(self->session->xrdp_ini);
|
||||||
fd = g_file_open(cfg_file); /* xrdp.ini */
|
|
||||||
if (fd != -1)
|
if (fd != -1)
|
||||||
{
|
{
|
||||||
names = list_create();
|
names = list_create();
|
||||||
@ -790,7 +787,9 @@ xrdp_wm_init(struct xrdp_wm *self)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
log_message(LOG_LEVEL_ERROR,"xrdp_wm_init: Could not read xrdp.ini file %s", cfg_file);
|
log_message(LOG_LEVEL_ERROR,
|
||||||
|
"xrdp_wm_init: Could not read xrdp.ini file %s",
|
||||||
|
self->session->xrdp_ini);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user