Skip to content

Commit 4736271

Browse files
committed
Remove sesmanruntimedir
Now we've made the XRDP_SOCKET_PATH only writeable by root, it's safe to move the sesman socket back into this directory. We no longer need a separate sesmanruntimedir
1 parent d830fef commit 4736271

9 files changed

+31
-64
lines changed

configure.ac

-7
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ AC_ARG_WITH([socketdir],
6262
[], [with_socketdir="$runstatedir/xrdp"])
6363
AC_SUBST([socketdir], [$with_socketdir])
6464

65-
AC_ARG_WITH([sesmanruntimedir],
66-
[AS_HELP_STRING([--with-sesmanruntimedir=DIR],
67-
[Use directory for sesman runtime data (default: RUNSTATEDIR/xrdp-sesman)])],
68-
[], [with_sesmanruntimedir="$runstatedir/xrdp-sesman"])
69-
AC_SUBST([sesmanruntimedir], [$with_sesmanruntimedir])
70-
7165
AC_ARG_WITH([systemdsystemunitdir],
7266
AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files, no to disable]),
7367
[], [
@@ -655,7 +649,6 @@ echo " pamconfdir $pamconfdir"
655649
echo " localstatedir $localstatedir"
656650
echo " runstatedir $runstatedir"
657651
echo " socketdir $socketdir"
658-
echo " sesmanruntimedir $sesmanruntimedir"
659652
echo ""
660653
echo " unit tests performable $perform_unit_tests"
661654
echo ""

docs/man/Makefile.am

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ SUBST_VARS = sed \
2727
-e 's|@localstatedir[@]|$(localstatedir)|g' \
2828
-e 's|@sysconfdir[@]|$(sysconfdir)|g' \
2929
-e 's|@socketdir[@]|$(socketdir)|g' \
30-
-e 's|@sesmanruntimedir[@]|$(sesmanruntimedir)|g' \
3130
-e 's|@xrdpconfdir[@]|$(sysconfdir)/xrdp|g' \
3231
-e 's|@xrdpdatadir[@]|$(datadir)/xrdp|g' \
3332
-e 's|@xrdphomeurl[@]|http://www.xrdp.org/|g'

docs/man/sesman.ini.5.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ In this instance, the system administrator is responsible for ensuring
5757
the socket can only be created by a suitably privileged process.
5858
.PP
5959
If the parameter does not start with a '/', a name within
60-
@sesmanruntimedir@ is used.
60+
@socketdir@ is used.
6161
.RE
6262

6363
.TP

docs/man/xrdp-sesadmin.8.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Retained for compatibility, but ignored.
2828
.BI \-i= port
2929
The sesman \fIUNIX domain socket\fP to connect to.
3030
Defaults to \fBsesman.socket\fP.
31-
If no path is specified for the socket, a default of @sesmanruntimedir@ is used.
31+
If no path is specified for the socket, a default of @socketdir@ is used.
3232

3333
.TP
3434
.BI \-c= command

docs/man/xrdp-sesman.8.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ not running \fBxrdp\-sesman\fR as a daemon.
7070
.br
7171
@localstatedir@/run/xrdp\-sesman.pid
7272
.br
73-
@sesmanruntimedir@/sesman.socket
73+
@socketdir@/sesman.socket
7474

7575
.SH "AUTHORS"
7676

libipm/Makefile.am

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
AM_CPPFLAGS = \
3-
-DSESMAN_RUNTIME_PATH=\"${sesmanruntimedir}\" \
43
-DXRDP_SOCKET_ROOT_PATH=\"${socketdir}\" \
54
-I$(top_srcdir)/common
65

libipm/scp.c

+21-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include <config_ac.h>
2828
#endif
2929

30+
#include <ctype.h>
31+
3032
#include "scp.h"
3133
#include "libipm.h"
3234
#include "guid.h"
@@ -76,6 +78,23 @@ scp_msgno_to_str(enum scp_msg_code n, char *buff, unsigned int buff_size)
7678
return buff;
7779
}
7880

81+
/*****************************************************************************/
82+
/**
83+
* Helper function returning 1 if the passed-in string is an integer >= 0
84+
*/
85+
static int is_positive_int(const char *s)
86+
{
87+
for ( ; *s != '\0' ; ++s)
88+
{
89+
if (!isdigit(*s))
90+
{
91+
return 0;
92+
}
93+
}
94+
95+
return 1;
96+
}
97+
7998
/*****************************************************************************/
8099
int
81100
scp_port_to_unix_domain_path(const char *port, char *buff,
@@ -111,7 +130,7 @@ scp_port_to_unix_domain_path(const char *port, char *buff,
111130
{
112131
port = SCP_LISTEN_PORT_BASE_STR;
113132
}
114-
else if (g_strcmp(port, "3350") == 0)
133+
else if (is_positive_int(port))
115134
{
116135
/* Version v0.9.x and earlier of xrdp used a TCP port
117136
* number. If we come across this, we'll ignore it for
@@ -121,7 +140,7 @@ scp_port_to_unix_domain_path(const char *port, char *buff,
121140
port = SCP_LISTEN_PORT_BASE_STR;
122141
}
123142

124-
result = g_snprintf(buff, bufflen, SESMAN_RUNTIME_PATH "/%s", port);
143+
result = g_snprintf(buff, bufflen, XRDP_SOCKET_ROOT_PATH "/%s", port);
125144
}
126145

127146
return result;

sesman/Makefile.am

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ AM_CPPFLAGS = \
77
-DXRDP_LIBEXEC_PATH=\"${libexecdir}/xrdp\" \
88
-DXRDP_PID_PATH=\"${localstatedir}/run\" \
99
-DXRDP_SOCKET_ROOT_PATH=\"${socketdir}\" \
10-
-DSESMAN_RUNTIME_PATH=\"${sesmanruntimedir}\" \
1110
-I$(top_srcdir)/sesman/libsesman \
1211
-I$(top_srcdir)/common \
1312
-I$(top_srcdir)/libipm

sesman/sesman.c

+7-49
Original file line numberDiff line numberDiff line change
@@ -193,45 +193,6 @@ sesman_process_params(int argc, char **argv,
193193
return 0;
194194
}
195195

196-
/******************************************************************************/
197-
static int
198-
create_sesman_runtime_dir(void)
199-
{
200-
int rv = -1;
201-
/* Make sure if we create the directory, there's no gap where it
202-
* may have the wrong permissions */
203-
int entry_umask = g_umask_hex(0x755);
204-
205-
if (!g_directory_exist(SESMAN_RUNTIME_PATH) &&
206-
!g_create_dir(SESMAN_RUNTIME_PATH))
207-
{
208-
LOG(LOG_LEVEL_ERROR,
209-
"Can't create runtime directory '"
210-
SESMAN_RUNTIME_PATH "' [%s]", g_get_strerror());
211-
}
212-
else if (g_chown(SESMAN_RUNTIME_PATH, g_getuid(), g_getuid()) != 0)
213-
{
214-
LOG(LOG_LEVEL_ERROR,
215-
"Can't set ownership of sesman runtime directory [%s]",
216-
g_get_strerror());
217-
}
218-
else if (g_chmod_hex(SESMAN_RUNTIME_PATH, 0x755) != 0)
219-
{
220-
/* This might seem redundant, but there's a chance the
221-
* directory already exists */
222-
LOG(LOG_LEVEL_ERROR,
223-
"Can't set permissions of sesman runtime directory [%s]",
224-
g_get_strerror());
225-
}
226-
else
227-
{
228-
rv = 0;
229-
}
230-
g_umask_hex(entry_umask);
231-
232-
return rv;
233-
}
234-
235196
/******************************************************************************/
236197
static int sesman_listen_test(struct config_sesman *cfg)
237198
{
@@ -694,24 +655,24 @@ create_xrdp_socket_root_path(void)
694655

695656
/* Create the path using 0755 permissions */
696657
int old_umask = g_umask_hex(0x22);
697-
(void)g_create_path(XRDP_SOCKET_PATH"/");
658+
(void)g_create_path(XRDP_SOCKET_ROOT_PATH"/");
698659
(void)g_umask_hex(old_umask);
699660

700661
/* Check the ownership and permissions on the last path element
701662
* are as expected */
702-
if (g_chown(XRDP_SOCKET_PATH, uid, gid) != 0)
663+
if (g_chown(XRDP_SOCKET_ROOT_PATH, uid, gid) != 0)
703664
{
704665
LOG(LOG_LEVEL_ERROR,
705666
"create_xrdp_socket_root_path: Can't set owner of %s to %d:%d",
706-
XRDP_SOCKET_PATH, uid, gid);
667+
XRDP_SOCKET_ROOT_PATH, uid, gid);
707668
return 1;
708669
}
709670

710-
if (g_chmod_hex(XRDP_SOCKET_PATH, 0x755) != 0)
671+
if (g_chmod_hex(XRDP_SOCKET_ROOT_PATH, 0x755) != 0)
711672
{
712673
LOG(LOG_LEVEL_ERROR,
713674
"create_xrdp_socket_root_path: Can't set perms of %s to 0x755",
714-
XRDP_SOCKET_PATH);
675+
XRDP_SOCKET_ROOT_PATH);
715676
return 1;
716677
}
717678

@@ -887,9 +848,9 @@ main(int argc, char **argv)
887848
}
888849
}
889850

890-
/* Create the runtime directory before we try to listen (or
851+
/* Create the socket directory before we try to listen (or
891852
* test-listen), so there's somewhere for the default socket to live */
892-
if (create_sesman_runtime_dir() != 0)
853+
if (create_xrdp_socket_root_path() != 0)
893854
{
894855
config_free(g_cfg);
895856
log_end();
@@ -963,9 +924,6 @@ main(int argc, char **argv)
963924
LOG(LOG_LEVEL_INFO,
964925
"starting xrdp-sesman with pid %d", g_pid);
965926

966-
/* make sure the socket directory exists */
967-
create_xrdp_socket_root_path();
968-
969927
/* make sure the /tmp/.X11-unix directory exists */
970928
if (!g_directory_exist("/tmp/.X11-unix"))
971929
{

0 commit comments

Comments
 (0)