The attached patch amends xrdp to allow for the xrdp configuration
files to be located in users home directories. This is for running xrdp
as a user process and not root daemon process. My use is to create the
config file dynamically and use xrdp as an rdp to rdp proxy. I will be
aiming to run multiple copies of xrdp.
Index: common/file.c
===================================================================
--- common/file.c (revision 3807)
+++ common/file.c (working copy)
@@ -29,6 +29,34 @@
#include "parse.h"
/*****************************************************************************/
+/* locate the correct copy of the requested file
+ * This may be a per user copy in the user home directory or a user xrdp sub
directory
+ * or a system wide copy. Puts full name of file in passed buffer
+ returns 0 if everything is ok
+ returns 1 if problem finding the file */
+int APP_CC
+file_config_name(const char* file_name, char* dest, int len )
+{
+
+ g_snprintf(dest, len, "%s/%s", g_getenv("HOME"), file_name);
+ if ( g_file_exist(dest) )
+ {
+ return 0;
+ }
+ g_snprintf(dest, len, "%s/xrdp/%s", g_getenv("HOME"), file_name);
+ if ( g_file_exist(dest) )
+ {
+ return 0;
+ }
+ g_snprintf(dest, len, "%s/%s", XRDP_CFG_PATH, file_name);
+ if ( g_file_exist(dest) )
+ {
+ return 0;
+ }
+ return 1;
+}
+
+/*****************************************************************************/
/* returns error
returns 0 if everything is ok
returns 1 if problem reading file */
Index: common/file.h
===================================================================
--- common/file.h (revision 3807)
+++ common/file.h (working copy)
@@ -28,6 +28,9 @@
#include "arch.h"
int APP_CC
+file_config_name(const char* file_name, char* dest, int len );
+
+int APP_CC
file_read_sections(int fd, struct list* names);
int APP_CC
file_by_name_read_sections(const char* file_name, struct list* names);
Index: libxrdp/xrdp_rdp.c
===================================================================
--- libxrdp/xrdp_rdp.c (revision 3807)
+++ libxrdp/xrdp_rdp.c (working copy)
@@ -68,7 +68,7 @@
items->auto_free = 1;
values = list_create();
values->auto_free = 1;
- g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
+ file_config_name("xrdp.ini", cfg_file, 255);
file_by_name_read_section(cfg_file, "globals", items, values);
for (index = 0; index < items->count; index++)
{
Index: libxrdp/xrdp_sec.c
===================================================================
--- libxrdp/xrdp_sec.c (revision 3807)
+++ libxrdp/xrdp_sec.c (working copy)
@@ -909,7 +909,7 @@
items->auto_free = 1;
values = list_create();
values->auto_free = 1;
- g_snprintf(key_file, 255, "%s/rsakeys.ini", XRDP_CFG_PATH);
+ file_config_name("rsakeys.ini", key_file, 255);
if (file_by_name_read_section(key_file, "keys", items, values) != 0)
{
/* this is a show stopper */
Index: libxrdp/xrdp_tcp.c
===================================================================
--- libxrdp/xrdp_tcp.c (revision 3807)
+++ libxrdp/xrdp_tcp.c (working copy)
@@ -74,12 +74,12 @@
int APP_CC
xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
{
- DEBUG((" in xrdp_tcp_send, gota send %d bytes", len));
+ DEBUG((" in xrdp_tcp_send, gota send %d bytes", 0));
if (trans_force_write_s(self->trans, s) != 0)
{
DEBUG((" error in trans_force_write_s"));
return 1;
}
- DEBUG((" out xrdp_tcp_send, sent %d bytes ok", len));
+ DEBUG((" out xrdp_tcp_send, sent %d bytes ok", 0));
return 0;
}
Index: sesman/chansrv/chansrv.c
===================================================================
--- sesman/chansrv/chansrv.c (revision 3807)
+++ sesman/chansrv/chansrv.c (working copy)
@@ -599,7 +599,7 @@
values = list_create();
values->auto_free = 1;
g_use_unix_socket = 0;
- g_snprintf(filename, 255, "%s/sesman.ini", XRDP_CFG_PATH);
+ file_config_name("sesman.ini", filename, 255);
if (file_by_name_read_section(filename, "Globals", names, values) == 0)
{
for (index = 0; index < names->count; index++)
Index: sesman/config.c
===================================================================
--- sesman/config.c (revision 3807)
+++ sesman/config.c (working copy)
@@ -62,7 +62,7 @@
struct list* param_v;
char cfg_file[256];
- g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
+ file_config_name("sesman.ini", cfg_file, 255);
fd = g_file_open(cfg_file);
if (-1 == fd)
{
Index: xrdp/xrdp_listen.c
===================================================================
--- xrdp/xrdp_listen.c (revision 3807)
+++ xrdp/xrdp_listen.c (working copy)
@@ -132,7 +132,7 @@
/* default to port 3389 */
g_strncpy(port, "3389", port_bytes - 1);
/* see if port is in xrdp.ini file */
- g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
+ file_config_name("xrdp.ini", cfg_file, 255);
fd = g_file_open(cfg_file);
if (fd > 0)
{
Index: xrdp/xrdp_login_wnd.c
===================================================================
--- xrdp/xrdp_login_wnd.c (revision 3807)
+++ xrdp/xrdp_login_wnd.c (working copy)
@@ -399,7 +399,7 @@
section_names->auto_free = 1;
section_values = list_create();
section_values->auto_free = 1;
- g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
+ file_config_name("xrdp.ini", cfg_file, 255);
fd = g_file_open(cfg_file); /* xrdp.ini */
if (fd < 1)
{
Index: xrdp/xrdp_mm.c
===================================================================
--- xrdp/xrdp_mm.c (revision 3807)
+++ xrdp/xrdp_mm.c (working copy)
@@ -729,7 +729,7 @@
/* default to port 3350 */
g_strncpy(port, "3350", port_bytes - 1);
/* see if port is in xrdp.ini file */
- g_snprintf(cfg_file, 255, "%s/sesman.ini", XRDP_CFG_PATH);
+ file_config_name("sesman.ini", cfg_file, 255);
fd = g_file_open(cfg_file);
if (fd > 0)
{
Index: xrdp/xrdp_wm.c
===================================================================
--- xrdp/xrdp_wm.c (revision 3807)
+++ xrdp/xrdp_wm.c (working copy)
@@ -384,7 +384,7 @@
self->screen->bg_color = self->black;
if (self->session->client_info->rdp_autologin)
{
- g_snprintf(cfg_file, 255, "%s/xrdp.ini", XRDP_CFG_PATH);
+ file_config_name("xrdp.ini", cfg_file, 255);
fd = g_file_open(cfg_file); /* xrdp.ini */
if (fd > 0)
{
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
xrdp-devel mailing list
xrdp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xrdp-devel