use unix domain socket for xrdp-X11rdp connection

This commit is contained in:
Jay Sorg 2012-03-15 21:42:39 -07:00
parent ffa5149a8f
commit e9c58226ba
3 changed files with 40 additions and 3 deletions

View File

@ -29,6 +29,7 @@ param1=-bs
param2=-ac
param3=-nolisten
param4=tcp
param5=-uds
[Xvnc]
param1=-bs

View File

@ -373,6 +373,7 @@ xrdp_mm_setup_mod2(struct xrdp_mm* self)
int rv;
int key_flags;
int device_flags;
int use_uds;
g_memset(text,0,sizeof(char) * 256);
rv = 1;
@ -396,7 +397,22 @@ xrdp_mm_setup_mod2(struct xrdp_mm* self)
}
else if (self->code == 10) /* X11rdp */
{
g_snprintf(text, 255, "%d", 6200 + self->display);
use_uds = 1;
if (xrdp_mm_get_value(self, "ip", text, 255) == 0)
{
if (g_strcmp(text, "127.0.0.1") != 0)
{
use_uds = 0;
}
}
if (use_uds)
{
g_snprintf(text, 255, "/tmp/.xrdp/xrdp_display_%d", self->display);
}
else
{
g_snprintf(text, 255, "%d", 6200 + self->display);
}
}
else
{

View File

@ -130,6 +130,7 @@ lib_mod_connect(struct mod* mod)
int len;
int i;
int index;
int use_uds;
struct stream* s;
char con_port[256];
@ -156,15 +157,34 @@ lib_mod_connect(struct mod* mod)
}
make_stream(s);
g_sprintf(con_port, "%s", mod->port);
use_uds = 0;
if (con_port[0] == '/')
{
use_uds = 1;
}
mod->sck_closed = 0;
i = 0;
while (1)
{
mod->sck = g_tcp_socket();
if (use_uds)
{
mod->sck = g_tcp_local_socket();
}
else
{
mod->sck = g_tcp_socket();
}
g_tcp_set_non_blocking(mod->sck);
g_tcp_set_no_delay(mod->sck);
mod->server_msg(mod, "connecting...", 0);
error = g_tcp_connect(mod->sck, mod->ip, con_port);
if (use_uds)
{
error = g_tcp_local_connect(mod->sck, con_port);
}
else
{
error = g_tcp_connect(mod->sck, mod->ip, con_port);
}
if (error == -1)
{
if (g_tcp_last_error_would_block(mod->sck))