Skip to content

Commit b45630e

Browse files
authored
Merge pull request #3017 from matt335672/cherry_picks_to_v0_10
Cherry picks to v0 10
2 parents fc34c2b + dfa52c1 commit b45630e

File tree

12 files changed

+250
-199
lines changed

12 files changed

+250
-199
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,6 @@ jobs:
213213
- run: sudo scripts/install_astyle_dependencies_with_apt.sh
214214
- run: scripts/install_astyle.sh $ASTYLE_REPO $ASTYLE_VER
215215
- name: Format code with astyle
216-
run: scripts/run_astyle.sh
216+
run: scripts/run_astyle.sh -v $ASTYLE_VER
217217
- name: Check code formatting
218218
run: git diff --exit-code

common/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ libcommon_la_SOURCES = \
7171
$(PIXMAN_SOURCES)
7272

7373
libcommon_la_LIBADD = \
74-
-lpthread -lrt \
74+
-lpthread \
7575
$(OPENSSL_LIBS) \
7676
$(DLOPEN_LIBS)

common/os_calls.c

-17
Original file line numberDiff line numberDiff line change
@@ -434,23 +434,6 @@ g_tcp_socket(void)
434434
}
435435
}
436436

437-
option_len = sizeof(option_value);
438-
439-
if (getsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char *)&option_value,
440-
&option_len) == 0)
441-
{
442-
if (option_value < (1024 * 32))
443-
{
444-
option_value = 1024 * 32;
445-
option_len = sizeof(option_value);
446-
if (setsockopt(rv, SOL_SOCKET, SO_SNDBUF, (char *)&option_value,
447-
option_len) < 0)
448-
{
449-
LOG(LOG_LEVEL_ERROR, "g_tcp_socket: setsockopt() failed");
450-
}
451-
}
452-
}
453-
454437
return rv;
455438
}
456439

docs/man/xrdp.ini.5.in

+3-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ If set to \fB1\fP, \fBtrue\fP or \fByes\fP, no buffering will be performed in th
177177
\fBtcp_send_buffer_bytes\fP=\fIbuffer_size\fP
178178
.TP
179179
\fBtcp_recv_buffer_bytes\fP=\fIbuffer_size\fP
180-
Specify send/recv buffer sizes in bytes. The default value depends on operating system.
180+
Specify send/recv buffer sizes in bytes. The default value depends on
181+
the operating system. It is recommended not to set these on systems with
182+
dynamic TCP buffer sizing
181183

182184
.TP
183185
\fBtls_ciphers\fP=\fIcipher_suite\fP

instfiles/xrdp.service.in

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ EnvironmentFile=-@sysconfdir@/sysconfig/xrdp
1010
EnvironmentFile=-@sysconfdir@/default/xrdp
1111
ExecStart=@sbindir@/xrdp $XRDP_OPTIONS --nodaemon
1212
SystemCallArchitectures=native
13-
SystemCallFilter=@basic-io @file-system @io-event @ipc @network-io @process
14-
SystemCallFilter=@signal @system-service ioctl madvise sysinfo uname
15-
SystemCallErrorNumber=EPERM
13+
SystemCallFilter=@system-service
1614

1715
[Install]
1816
WantedBy=multi-user.target

scripts/run_astyle.sh

+46-28
Original file line numberDiff line numberDiff line change
@@ -2,66 +2,82 @@
22

33
# Script to run astyle on the code
44
#
5-
# Usage: /path/to/run_astyle.sh
5+
# Usage: /path/to/run_astyle.sh [ -v ASTYLE_VER]
66
#
7+
# - If -v ASTYLE_VER is specified, that version of astyle is run from
8+
# ~/astyle.local (whether or not it's there!). Use install_astyle.sh
9+
# to install a new version.
10+
711
# Note: the script must be run from the root directory of the xrdp repository
812

913
INSTALL_ROOT=~/astyle.local
10-
ASTYLE_FROM_XRDP=$INSTALL_ROOT/3.4.12/usr/bin/astyle
1114
MIN_ASTYLE_VER="3.1"
1215

1316
# ----------------------------------------------------------------------------
1417
# U S A G E
1518
# ----------------------------------------------------------------------------
1619
usage()
1720
{
18-
echo "** Usage: $0"
19-
echo " e.g. $0"
21+
echo "** Usage: $0 [ -v version]"
22+
echo " e.g. $0 -v 3.4.12"
2023
} >&2
2124

2225
# ----------------------------------------------------------------------------
2326
# M A I N
2427
# ----------------------------------------------------------------------------
28+
# Figure out ASTYLE setting, if any. Currently '-v' must be the first
29+
# argument on the command line.
30+
case "$1" in
31+
-v) # Version is separate parameter
32+
if [ $# -ge 2 ]; then
33+
ASTYLE="$INSTALL_ROOT/$2/usr/bin/astyle"
34+
shift 2
35+
else
36+
echo "** ignoring '-v' with no arg" >&2
37+
shift 1
38+
fi
39+
;;
40+
-v*) # Version is in same parameter
41+
# ${parameter#word} is not supported by classic Bourne shell,
42+
# but it is on bash, dash, etc. If it doesn't work on your shell,
43+
# don't use this form!
44+
ASTYLE="$INSTALL_ROOT/${1#-v}/usr/bin/astyle"
45+
shift 1
46+
esac
47+
48+
if [ -z "$ASTYLE" ]; then
49+
ASTYLE=astyle
50+
fi
51+
2552
if [ $# -ne 0 ]; then
2653
usage
2754
exit 1
2855
fi
2956

30-
# check if the built-in astyle meets the minimum requrements
31-
ASTYLE_FROM_OS_VER_OUTPUT=`astyle --version | grep "Artistic Style Version" | cut -d' ' -f4`
3257

33-
ASTYLE=""
34-
ERROR_MESSAGE=""
35-
if [ ! -z "$ASTYLE_FROM_OS_VER_OUTPUT" ]; then
36-
# astyle is installed, so check if it's version meets the minimum requirements
37-
LOWEST_VERSION=`echo -e "$MIN_ASTYLE_VER\n$ASTYLE_FROM_OS_VER_OUTPUT" | sort -V | head -n1`
38-
if [ "$MIN_ASTYLE_VER" = "$LOWEST_VERSION" ]; then
39-
ASTYLE=astyle
40-
else
58+
# check if the selected astyle meets the minimum requrements
59+
ASTYLE_VER_OUTPUT=`$ASTYLE --version 2>/dev/null | grep "Artistic Style Version" | cut -d' ' -f4`
60+
61+
if [ ! -z "$ASTYLE_VER_OUTPUT" ]; then
62+
# Check the version meets the minimum requirements
63+
LOWEST_VERSION=`{ echo "$MIN_ASTYLE_VER" ; echo "$ASTYLE_VER_OUTPUT"; } | sort -V | head -n1`
64+
if [ "$MIN_ASTYLE_VER" != "$LOWEST_VERSION" ]; then
4165
ERROR_MESSAGE="The version of astyle installed does not meet the minimum version requirement: >= $MIN_ASTYLE_VER "
4266
fi
43-
else
67+
elif [ "$ASTYLE" = astyle ]; then
4468
ERROR_MESSAGE="astyle is not installed on the system path"
45-
fi
46-
47-
if [ -z "$ASTYLE" ]; then
48-
# astyle from the os is invlid, fallback to the xrdp version if it is installed
49-
if [ -x "$ASTYLE_FROM_XRDP" ]; then
50-
ASTYLE="$ASTYLE_FROM_XRDP"
51-
ERROR_MESSAGE=""
52-
else
53-
ERROR_MESSAGE="${ERROR_MESSAGE}\nastyle $MIN_ASTYLE_VER is not installed at the expected path: $ASTYLE_FROM_XRDP"
54-
fi
69+
else
70+
ERROR_MESSAGE="Can't find $ASTYLE"
5571
fi
5672

5773
if [ ! -z "$ERROR_MESSAGE" ]; then
58-
echo "$ERROR_MESSAGE"
74+
echo "$ERROR_MESSAGE" >&2
5975
exit 1
6076
fi
6177

6278
if [ ! -f "astyle_config.as" ]; then
63-
echo "$0 must be run from the root xrdp repository directory which "
64-
echo "contains the 'astyle_config.as' file."
79+
echo "$0 must be run from the root xrdp repository directory which " >&2
80+
echo "contains the 'astyle_config.as' file." >&2
6581
exit 2
6682
fi
6783

@@ -72,3 +88,5 @@ ASTYLE_FLAGS="--options=astyle_config.as --exclude=third_party ./\*.c ./\*.h"
7288
echo "Command: $ASTYLE $ASTYLE_FLAGS"
7389
"$ASTYLE" $ASTYLE_FLAGS
7490
}
91+
92+
exit $?

sesman/scp_process.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -323,21 +323,31 @@ process_logout_request(struct pre_session_item *psi)
323323
static int
324324
create_xrdp_socket_path(uid_t uid)
325325
{
326+
// Owner all permissions, group read+execute
327+
#define RWX_PERMS 0x750
328+
326329
int rv = 1;
327330
const char *sockdir_group = g_cfg->sec.session_sockdir_group;
328331
int gid = 0; // Default if no group specified
329332

330333
char sockdir[XRDP_SOCKETS_MAXPATH];
331334
g_snprintf(sockdir, sizeof(sockdir), XRDP_SOCKET_PATH, (int)uid);
332335

333-
// Create directory permissions 0x750, if it doesn't exist already.
334-
int old_umask = g_umask_hex(0x750 ^ 0x777);
336+
// Create directory permissions RWX_PERMS, if it doesn't exist already
337+
// (our os_calls layer doesn't allow us to set the SGID bit here)
338+
int old_umask = g_umask_hex(RWX_PERMS ^ 0x777);
335339
if (!g_directory_exist(sockdir) && !g_create_dir(sockdir))
336340
{
337341
LOG(LOG_LEVEL_ERROR,
338342
"create_xrdp_socket_path: Can't create %s [%s]",
339343
sockdir, g_get_strerror());
340344
}
345+
else if (g_chmod_hex(sockdir, RWX_PERMS | 0x2000) != 0)
346+
{
347+
LOG(LOG_LEVEL_ERROR,
348+
"create_xrdp_socket_path: Can't set SGID bit on %s [%s]",
349+
sockdir, g_get_strerror());
350+
}
341351
else if (sockdir_group != NULL && sockdir_group[0] != '\0' &&
342352
g_getgroup_info(sockdir_group, &gid) != 0)
343353
{
@@ -358,6 +368,7 @@ create_xrdp_socket_path(uid_t uid)
358368
(void)g_umask_hex(old_umask);
359369

360370
return rv;
371+
#undef RWX_PERMS
361372
}
362373

363374
/******************************************************************************/

xrdp/xrdp.ini.in

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ tcp_nodelay=true
3535
; if the network connection disappear without close messages the connection will be closed
3636
tcp_keepalive=true
3737

38-
; set tcp send/recv buffer (for experts)
38+
; set tcp send/recv buffer
39+
; These parameters are largely historic. On systems with dynamic TCP
40+
; buffer sizes, setting them manually will either impact performance or
41+
; waste memory
3942
#tcp_send_buffer_bytes=32768
4043
#tcp_recv_buffer_bytes=32768
4144

0 commit comments

Comments
 (0)