X11rdp: respect XRDP_SOCKET_PATH environment variable

This commit is contained in:
Pavel Roskin 2017-03-14 21:57:47 -07:00 committed by jsorg71
parent 58c9cb43e9
commit 5c8f050c1a
4 changed files with 30 additions and 8 deletions

View File

@ -348,6 +348,8 @@ int
g_directory_exist(const char* dirname);
int
g_chmod_hex(const char* filename, int flags);
const char *
g_socket_dir(void);
void
hexdump(unsigned char *p, unsigned int len);
void

View File

@ -769,7 +769,8 @@ ddxGiveUp(void)
{
sprintf(unixSocketName, "/tmp/.X11-unix/X%s", display);
unlink(unixSocketName);
sprintf(unixSocketName, "/tmp/.xrdp/xrdp_disconnect_display_%s", display);
sprintf(unixSocketName, "%s/xrdp_disconnect_display_%s",
g_socket_dir(), display);
unlink(unixSocketName);
if (g_uds_data[0] != 0)
@ -823,7 +824,7 @@ ddxUseMsg(void)
ErrorF("X11rdp specific options\n");
ErrorF("-geometry WxH set framebuffer width & height\n");
ErrorF("-depth D set framebuffer depth\n");
ErrorF("-uds create and listen on /tmp/.xrdp/xrdp_display_x\n");
ErrorF("-uds create and listen on xrdp_display_x\n");
ErrorF("\n");
exit(1);
}

View File

@ -517,6 +517,22 @@ g_chmod_hex(const char *filename, int flags)
return chmod(filename, fl);
}
/*****************************************************************************/
/* returns directory where UNIX sockets are located */
const char *
g_socket_dir(void)
{
const char *socket_dir;
socket_dir = getenv("XRDP_SOCKET_PATH");
if (socket_dir == NULL || socket_dir[0] == '\0')
{
socket_dir = "/tmp/.xrdp";
}
return socket_dir;
}
/* produce a hex dump */
void
hexdump(unsigned char *p, unsigned int len)

View File

@ -1233,16 +1233,19 @@ rdpup_init(void)
char text[256];
char *ptext;
int i;
const char *socket_dir;
if (!g_directory_exist("/tmp/.xrdp"))
socket_dir = g_socket_dir();
if (!g_directory_exist(socket_dir))
{
if (!g_create_dir("/tmp/.xrdp"))
if (!g_create_dir(socket_dir))
{
LLOGLN(0, ("rdpup_init: g_create_dir failed"));
LLOGLN(0, ("rdpup_init: g_create_dir(%s) failed", socket_dir));
return 0;
}
g_chmod_hex("/tmp/.xrdp", 0x1777);
g_chmod_hex(socket_dir, 0x1777);
}
i = atoi(display);
@ -1266,7 +1269,7 @@ rdpup_init(void)
if (g_use_uds)
{
g_sprintf(g_uds_data, "/tmp/.xrdp/xrdp_display_%s", display);
g_sprintf(g_uds_data, "%s/xrdp_display_%s", socket_dir, display);
if (g_listen_sck == 0)
{
@ -1304,7 +1307,7 @@ rdpup_init(void)
if (g_dis_listen_sck != 0)
{
g_sprintf(text, "/tmp/.xrdp/xrdp_disconnect_display_%s", display);
g_sprintf(text, "%s/xrdp_disconnect_display_%s", socket_dir, display);
if (g_tcp_local_bind(g_dis_listen_sck, text) == 0)
{