Make socket directory configurable, don't hardcode /tmp/.xrdp

Use XRDP_SOCKET_PATH in file_loc.h

Don't define any non-socket paths in file_loc.h, they should come from
the makefiles.

Define all paths unconditionally, they should not be defined elsewhere.

Pass XRDP_SOCKET_PATH as environment variable to the backends.
master
Pavel Roskin 8 years ago committed by jsorg71
parent fc2572f60b
commit 58c9cb43e9

@ -16,7 +16,8 @@ AM_CPPFLAGS = \
-DXRDP_SBIN_PATH=\"${sbindir}\" \ -DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \ -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
-DXRDP_LOG_PATH=\"${localstatedir}/log\" -DXRDP_LOG_PATH=\"${localstatedir}/log\" \
-DXRDP_SOCKET_PATH=\"${socketdir}\"
if XRDP_DEBUG if XRDP_DEBUG
AM_CPPFLAGS += -DXRDP_DEBUG AM_CPPFLAGS += -DXRDP_DEBUG

@ -21,48 +21,11 @@
#if !defined(FILE_LOC_H) #if !defined(FILE_LOC_H)
#define FILE_LOC_H #define FILE_LOC_H
#if !defined(XRDP_CFG_PATH) #define XRDP_CHANSRV_STR XRDP_SOCKET_PATH "/xrdp_chansrv_socket_%d"
#define XRDP_CFG_PATH "/etc/xrdp" #define CHANSRV_PORT_OUT_STR XRDP_SOCKET_PATH "/xrdp_chansrv_audio_out_socket_%d"
#endif #define CHANSRV_PORT_IN_STR XRDP_SOCKET_PATH "/xrdp_chansrv_audio_in_socket_%d"
#define CHANSRV_API_STR XRDP_SOCKET_PATH "/xrdpapi_%d"
#if !defined(XRDP_PID_PATH) #define XRDP_X11RDP_STR XRDP_SOCKET_PATH "/xrdp_display_%d"
#define XRDP_PID_PATH "/var/run" #define XRDP_DISCONNECT_STR XRDP_SOCKET_PATH "/xrdp_disconnect_display_%d"
#endif
#if !defined(XRDP_SBIN_PATH)
#define XRDP_SBIN_PATH "/usr/local/sbin"
#endif
#if !defined(XRDP_SHARE_PATH)
#define XRDP_SHARE_PATH "/usr/local/share/xrdp"
#endif
#if !defined(XRDP_MODULE_PATH)
#define XRDP_MODULE_PATH "/usr/local/lib/xrdp"
#endif
#if !defined(XRDP_LOG_PATH)
#define XRDP_LOG_PATH "/var/log"
#endif
#if !defined(XRDP_CHANSRV_STR)
#define XRDP_CHANSRV_STR "/tmp/.xrdp/xrdp_chansrv_socket_%d"
#endif
#if !defined(CHANSRV_PORT_OUT_STR)
#define CHANSRV_PORT_OUT_STR "/tmp/.xrdp/xrdp_chansrv_audio_out_socket_%d"
#endif
#if !defined(CHANSRV_PORT_IN_STR)
#define CHANSRV_PORT_IN_STR "/tmp/.xrdp/xrdp_chansrv_audio_in_socket_%d"
#endif
#if !defined(CHANSRV_API_STR)
#define CHANSRV_API_STR "/tmp/.xrdp/xrdpapi_%d"
#endif
#if !defined(XRDP_X11RDP_STR)
#define XRDP_X11RDP_STR "/tmp/.xrdp/xrdp_display_%d"
#endif
#endif #endif

@ -111,18 +111,19 @@ g_rm_temp_dir(void)
int int
g_mk_temp_dir(const char *app_name) g_mk_temp_dir(const char *app_name)
{ {
if (!g_directory_exist("/tmp/.xrdp")) if (!g_directory_exist(XRDP_SOCKET_PATH))
{ {
if (!g_create_dir("/tmp/.xrdp")) if (!g_create_dir(XRDP_SOCKET_PATH))
{ {
/* if failed, still check if it got created by someone else */ /* if failed, still check if it got created by someone else */
if (!g_directory_exist("/tmp/.xrdp")) if (!g_directory_exist(XRDP_SOCKET_PATH))
{ {
printf("g_mk_temp_dir: g_create_dir failed\n"); printf("g_mk_temp_dir: g_create_dir(%s) failed\n",
XRDP_SOCKET_PATH);
return 1; return 1;
} }
} }
g_chmod_hex("/tmp/.xrdp", 0x1777); g_chmod_hex(XRDP_SOCKET_PATH, 0x1777);
} }
return 0; return 0;
} }

@ -47,6 +47,12 @@ AM_CONDITIONAL(FREEBSD, [test "x$freebsd" = xyes])
AM_CONDITIONAL(OPENBSD, [test "x$openbsd" = xyes]) AM_CONDITIONAL(OPENBSD, [test "x$openbsd" = xyes])
AM_CONDITIONAL(NETBSD, [test "x$netbsd" = xyes]) AM_CONDITIONAL(NETBSD, [test "x$netbsd" = xyes])
AC_ARG_WITH([socketdir],
[AS_HELP_STRING([--with-socketdir=DIR],
[Use directory for UNIX sockets (default: /tmp/.xrdp)])],
[], [with_socketdir="/tmp/.xrdp"])
AC_SUBST([socketdir], [$with_socketdir])
AC_ARG_WITH([systemdsystemunitdir], AC_ARG_WITH([systemdsystemunitdir],
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]), AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
[], [ [], [

@ -17,7 +17,8 @@ SUBST_VARS = sed \
-e 's|@PACKAGE_VERSION[@]|$(PACKAGE_VERSION)|g' \ -e 's|@PACKAGE_VERSION[@]|$(PACKAGE_VERSION)|g' \
-e 's|@bindir[@]|$(bindir)|g' \ -e 's|@bindir[@]|$(bindir)|g' \
-e 's|@localstatedir[@]|$(localstatedir)|g' \ -e 's|@localstatedir[@]|$(localstatedir)|g' \
-e 's|@sysconfdir[@]|$(sysconfdir)|g' -e 's|@sysconfdir[@]|$(sysconfdir)|g' \
-e 's|@socketdir[@]|$(socketdir)|g'
subst_verbose = $(subst_verbose_@AM_V@) subst_verbose = $(subst_verbose_@AM_V@)
subst_verbose_ = $(subst_verbose_@AM_DEFAULT_V@) subst_verbose_ = $(subst_verbose_@AM_DEFAULT_V@)

@ -30,10 +30,10 @@ Dynamic Virtual Channel
.SH FILES .SH FILES
.TP .TP
.I /tmp/.xrdp/xrdp_chansrv_socket_* .I @socketdir@/xrdp_chansrv_socket_*
UNIX socket used by external programs to implement channels. UNIX socket used by external programs to implement channels.
.TP .TP
.I /tmp/.xrdp/xrdp_api_* .I @socketdir@/xrdp_api_*
UNIX socket used by \fBxrdp\-chansrv\fP to communicate with \fBxrdp\-sesman\fP. UNIX socket used by \fBxrdp\-chansrv\fP to communicate with \fBxrdp\-sesman\fP.
.TP .TP
.I $XDG_DATA_HOME/xrdp/xrdp-chansrv.log .I $XDG_DATA_HOME/xrdp/xrdp-chansrv.log

@ -16,7 +16,7 @@ to get the default host and display number.
.SH FILES .SH FILES
.TP .TP
.I /tmp/.xrdp/xrdp_disconnect_display_* .I @socketdir@/xrdp_disconnect_display_*
UNIX socket used to communicate with the \fBxrdp\fP(8) session manager. UNIX socket used to communicate with the \fBxrdp\fP(8) session manager.
.SH KNOWN ISSUES .SH KNOWN ISSUES

@ -6,6 +6,7 @@ AM_CPPFLAGS = \
-DXRDP_SBIN_PATH=\"${sbindir}\" \ -DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \ -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
-I$(top_srcdir)/common \ -I$(top_srcdir)/common \
-I$(top_srcdir)/sesman/libscp -I$(top_srcdir)/sesman/libscp

@ -9,6 +9,7 @@ AM_CPPFLAGS = \
-DXRDP_SBIN_PATH=\"${sbindir}\" \ -DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \ -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
-I$(top_srcdir)/common -I$(top_srcdir)/common
if XRDP_DEBUG if XRDP_DEBUG

@ -68,6 +68,7 @@ typedef bool pa_bool_t;
#endif #endif
#include "module-xrdp-sink-symdef.h" #include "module-xrdp-sink-symdef.h"
#include "../common/file_loc.h"
PA_MODULE_AUTHOR("Jay Sorg"); PA_MODULE_AUTHOR("Jay Sorg");
PA_MODULE_DESCRIPTION("xrdp sink"); PA_MODULE_DESCRIPTION("xrdp sink");
@ -84,7 +85,6 @@ PA_MODULE_USAGE(
#define DEFAULT_SINK_NAME "xrdp-sink" #define DEFAULT_SINK_NAME "xrdp-sink"
#define BLOCK_USEC 30000 #define BLOCK_USEC 30000
//#define BLOCK_USEC (PA_USEC_PER_SEC * 2) //#define BLOCK_USEC (PA_USEC_PER_SEC * 2)
#define CHANSRV_PORT_STR "/tmp/.xrdp/xrdp_chansrv_audio_out_socket_%d"
struct userdata { struct userdata {
pa_core *core; pa_core *core;

@ -55,6 +55,7 @@ typedef bool pa_bool_t;
#endif #endif
#include "module-xrdp-source-symdef.h" #include "module-xrdp-source-symdef.h"
#include "../common/file_loc.h"
PA_MODULE_AUTHOR("Laxmikant Rashinkar"); PA_MODULE_AUTHOR("Laxmikant Rashinkar");
PA_MODULE_DESCRIPTION("xrdp source"); PA_MODULE_DESCRIPTION("xrdp source");
@ -72,7 +73,6 @@ PA_MODULE_USAGE(
#define DEFAULT_SOURCE_NAME "xrdp-source" #define DEFAULT_SOURCE_NAME "xrdp-source"
#define DEFAULT_LATENCY_TIME 10 #define DEFAULT_LATENCY_TIME 10
#define MAX_LATENCY_USEC 1000 #define MAX_LATENCY_USEC 1000
#define CHANSRV_PORT_STR "/tmp/.xrdp/xrdp_chansrv_audio_in_socket_%d"
struct userdata { struct userdata {
pa_core *core; pa_core *core;

@ -668,6 +668,7 @@ session_start_fork(tbus data, tui8 type, struct SCP_SESSION *s)
g_setenv("XRDP_SESMAN_MAX_DISC_TIME", text, 1); g_setenv("XRDP_SESMAN_MAX_DISC_TIME", text, 1);
g_snprintf(text, 255, "%d", g_cfg->sess.kill_disconnected); g_snprintf(text, 255, "%d", g_cfg->sess.kill_disconnected);
g_setenv("XRDP_SESMAN_KILL_DISCONNECTED", text, 1); g_setenv("XRDP_SESMAN_KILL_DISCONNECTED", text, 1);
g_setenv("XRDP_SOCKET_PATH", XRDP_SOCKET_PATH, 1);
/* prepare the Xauthority stuff */ /* prepare the Xauthority stuff */
if (g_getenv("XAUTHORITY") != NULL) if (g_getenv("XAUTHORITY") != NULL)

@ -3,6 +3,7 @@ AM_CPPFLAGS = \
-DXRDP_SBIN_PATH=\"${sbindir}\" \ -DXRDP_SBIN_PATH=\"${sbindir}\" \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \ -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
-I$(top_srcdir)/common \ -I$(top_srcdir)/common \
-I$(top_srcdir)/sesman/libscp \ -I$(top_srcdir)/sesman/libscp \
-I$(top_srcdir)/sesman -I$(top_srcdir)/sesman

@ -27,6 +27,8 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
#include "file_loc.h"
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int sck; int sck;
@ -54,7 +56,7 @@ int main(int argc, char **argv)
dis = strtol(display + 1, &p, 10); dis = strtol(display + 1, &p, 10);
memset(&sa, 0, sizeof(sa)); memset(&sa, 0, sizeof(sa));
sa.sun_family = AF_UNIX; sa.sun_family = AF_UNIX;
sprintf(sa.sun_path, "/tmp/.xrdp/xrdp_disconnect_display_%d", dis); sprintf(sa.sun_path, XRDP_DISCONNECT_STR, dis);
if (access(sa.sun_path, F_OK) != 0) if (access(sa.sun_path, F_OK) != 0)
{ {

@ -9,6 +9,7 @@ AM_CPPFLAGS = \
-DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \ -DXRDP_SHARE_PATH=\"${datadir}/xrdp\" \
-DXRDP_PID_PATH=\"${localstatedir}/run\" \ -DXRDP_PID_PATH=\"${localstatedir}/run\" \
-DXRDP_MODULE_PATH=\"${moduledir}\" \ -DXRDP_MODULE_PATH=\"${moduledir}\" \
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
-I$(top_builddir) \ -I$(top_builddir) \
-I$(top_srcdir)/common \ -I$(top_srcdir)/common \
-I$(top_srcdir)/libxrdp -I$(top_srcdir)/libxrdp

@ -3,6 +3,10 @@ EXTRA_DIST = \
vrplayer.c \ vrplayer.c \
vrplayer.mk vrplayer.mk
AM_CPPFLAGS = \
-DXRDP_SOCKET_PATH=\"${socketdir}\" \
-I$(top_srcdir)/common
module_LTLIBRARIES = \ module_LTLIBRARIES = \
libxrdpapi.la libxrdpapi.la

@ -39,6 +39,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/un.h> #include <sys/un.h>
#include "file_loc.h"
#include "xrdpapi.h" #include "xrdpapi.h"
struct wts_obj struct wts_obj
@ -148,7 +149,7 @@ WTSVirtualChannelOpenEx(unsigned int SessionId, const char *pVirtualName,
memset(&s, 0, sizeof(struct sockaddr_un)); memset(&s, 0, sizeof(struct sockaddr_un));
s.sun_family = AF_UNIX; s.sun_family = AF_UNIX;
bytes = sizeof(s.sun_path); bytes = sizeof(s.sun_path);
snprintf(s.sun_path, bytes - 1, "/tmp/.xrdp/xrdpapi_%d", wts->display_num); snprintf(s.sun_path, bytes - 1, CHANSRV_API_STR, wts->display_num);
s.sun_path[bytes - 1] = 0; s.sun_path[bytes - 1] = 0;
bytes = sizeof(struct sockaddr_un); bytes = sizeof(struct sockaddr_un);

Loading…
Cancel
Save