Skip to content

Commit

Permalink
Add XAuthorityInSystemDir option
Browse files Browse the repository at this point in the history
Add an option to allow XAUTHORITY to ber moved away from $HOME. This is
modelled on the lightdm 'user-authority-in-system-dir' option
  • Loading branch information
matt335672 committed Jan 13, 2025
1 parent d98c883 commit 968fbcf
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
10 changes: 9 additions & 1 deletion docs/man/sesman.ini.5.in
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ In this instance, the system administrator is responsible for ensuring
the socket can only be created by a suitably privileged process.
.PP
If the parameter does not start with a '/', a name within
@socketdir@ is used.
@socketdir@/\fI<uid>\fR is used.
.RE

.TP
Expand Down Expand Up @@ -251,6 +251,14 @@ The number of login attempts that are allowed on terminal server. If set
to \fI0\fR, unlimited attempts are allowed. If not specified, defaults to
\fI3\fR.

.TP
\fBXAuthorityInSystemDir\fR=\fI[no|yes]\fR
If set to \fByes\fR, xrdp will set XAUTHORITY to be in a system directory
(currently @socketdir@/\fI<uid>\fR) which is only accessible to the
logged-in user.
You may wish to use this if $HOME is NFS-mounted, or you are experiencing
other applications overwriting the default file.

.TP
\fBTerminalServerUsers\fR=\fIgroup\fR
Only the users belonging to the specified group are allowed to login on
Expand Down
7 changes: 7 additions & 0 deletions sesman/libsesman/sesman_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
*/
#define SESMAN_CFG_SECURITY "Security"
#define SESMAN_CFG_SEC_LOGIN_RETRY "MaxLoginRetry"
#define SESMAN_CFG_XAUTH_IN_SYSDIR "XAuthorityInSystemDir"
#define SESMAN_CFG_SEC_ALLOW_ROOT "AllowRootLogin"
#define SESMAN_CFG_SEC_USR_GROUP "TerminalServerUsers"
#define SESMAN_CFG_SEC_ADM_GROUP "TerminalServerAdmins"
Expand Down Expand Up @@ -307,6 +308,7 @@ config_read_security(int file, struct config_security *sc,
/* setting defaults */
sc->allow_root = 0;
sc->login_retry = 3;
sc->xauth_in_sysdir = 0;
sc->restrict_outbound_clipboard = 0;
sc->restrict_inbound_clipboard = 0;
sc->allow_alternate_shell = 1;
Expand All @@ -330,6 +332,10 @@ config_read_security(int file, struct config_security *sc,
{
sc->login_retry = g_atoi(value);
}
else if (0 == g_strcasecmp(buf, SESMAN_CFG_XAUTH_IN_SYSDIR))
{
sc->xauth_in_sysdir = g_text2bool(value);
}
else if (0 == g_strcasecmp(buf, SESMAN_CFG_SEC_USR_GROUP))
{
g_free(sc->ts_users);
Expand Down Expand Up @@ -672,6 +678,7 @@ config_dump(struct config_sesman *config)
g_writeln("Security configuration:");
g_writeln(" AllowRootLogin: %d", sc->allow_root);
g_writeln(" MaxLoginRetry: %d", sc->login_retry);
g_writeln(" XAuthorityInSystemDir: %d", sc->xauth_in_sysdir);
g_writeln(" AlwaysGroupCheck: %d", sc->ts_always_group_check);
g_writeln(" AllowAlternateShell: %d", sc->allow_alternate_shell);
#ifdef HAVE_SYS_PRCTL_H
Expand Down
6 changes: 6 additions & 0 deletions sesman/libsesman/sesman_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ struct config_security
* @brief maximum login attempts
*/
int login_retry;
/**
* @var x_authority_in_system_dir
* @brief Move XAUTHORITY to a system directory
*/
int xauth_in_sysdir;

/**
* @var ts_users
* @brief Terminal Server Users group
Expand Down
6 changes: 6 additions & 0 deletions sesman/sesexec/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ env_set_user(int uid, char **passwd_file, int display,
/* pulse source socket */
g_snprintf(text, sizeof(text), CHANSRV_PORT_IN_BASE_STR, display);
g_setenv("XRDP_PULSE_SOURCE_SOCKET", text, 1);
if (g_cfg->sec.xauth_in_sysdir)
{
g_snprintf(text, sizeof(text), XRDP_SOCKET_PATH "/Xauthority",
uid);
g_setenv("XAUTHORITY", text, 1);
}
if ((env_names != 0) && (env_values != 0) &&
(env_names->count == env_values->count))
{
Expand Down
2 changes: 1 addition & 1 deletion sesman/sesman.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ReconnectScript=reconnectwm.sh
[Security]
AllowRootLogin=true
MaxLoginRetry=4
XAuthorityInSystemDir=no
TerminalServerUsers=tsusers
TerminalServerAdmins=tsadmins
; When AlwaysGroupCheck=false access will be permitted
Expand Down Expand Up @@ -50,7 +51,6 @@ RestrictInboundClipboard=none
; be able to connect to your sessions.
#SessionSockdirGroup=xrdp


[Sessions]
;; X11DisplayOffset - x11 display number offset
; Type: integer
Expand Down

0 comments on commit 968fbcf

Please sign in to comment.