Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pam: debian: Explicitly include pam_limits for xrdp sessions #3343

Merged
merged 1 commit into from
Dec 17, 2024

Conversation

ximion
Copy link
Contributor

@ximion ximion commented Dec 14, 2024

Hello!
This change makes xrdp-sesman PAM explicitly request pam_limits in its Debian configuration.
This is needed, as on Debian, pam_limits is not automatically included for common sessions, and only for "login" sessions and session managers. So, xrdp has to include it explicitly to make limits take effect.
Without the change, limits might be set very low, which can yield a lot of really odd problems especially when running scientific software (we found out that things like MATLAB takes 15min to launch, and some Python code outright refuses to work. Especially for the MATLAB issue, the cause was fairly difficult to find).

This apparently has been a problem for a while, a web search yielded posts like https://florent.clairambault.fr/xrdp-and-the-ulimits-nofile-issue/ - but the solution given there isn't ideal, as it will alter the limits of system daemons as well, which may not be intended.

I think fixing this in xrdp is the better approach, and also way easier. We have been running with this configuration change for a year without any issues so far.

See https://wiki.debian.org/Limits for details on limits on Debian.
Thank you for considering the patch! :-)

Copy link
Member

@metalefty metalefty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@matt335672
Copy link
Member

I'm happy with the concept too - it seems like a great idea.

I've done a bit of checking around, and this appears to be the default on Fedora, Arch and openSuSE. In terms of major distros it's only the Debian family that's missing out.

@ximion - at the risk of seeming picky, could you move the line down in the file to sit with the rest of the session lines, like this? Then I'll merge it for you.

--- a/instfiles/pam.d/xrdp-sesman.debian
+++ b/instfiles/pam.d/xrdp-sesman.debian
@@ -5,8 +5,6 @@ auth     required  pam_env.so readenv=1 envfile=/etc/default/locale
 -auth    optional  pam_gnome_keyring.so
 -auth    optional  pam_kwallet5.so
 
-session    required   pam_limits.so
-
 @include common-account
 
 @include common-password
@@ -15,6 +13,7 @@ session    required   pam_limits.so
 session    required     pam_loginuid.so
 # Update wtmp/lastlog
 session    optional     pam_lastlog.so quiet
+session    required   pam_limits.so
 @include common-session
 -session optional  pam_gnome_keyring.so auto_start
 -session optional  pam_kwallet5.so auto_start

@metalefty metalefty added this to the v0.10.2 milestone Dec 16, 2024
@metalefty
Copy link
Member

Let's backport this one to v0.10 after the changes @matt335672 mentioned.

@matt335672
Copy link
Member

I agree. I'd like to make sure @ximion is happy with it before merging.

Copy link
Member

@metalefty metalefty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes required as @matt335672 mentioned.

This is required, as on Debian, pam_limits is not automatically included
for common sessions, and only for "login" sessions and session managers.
So, xrdp has to include it explicitly to make limits take effect.

See https://wiki.debian.org/Limits for details.
@ximion ximion force-pushed the wip/debian-pam-limits branch from 1f6b42b to f581d8e Compare December 16, 2024 16:22
@ximion
Copy link
Contributor Author

ximion commented Dec 16, 2024

@matt335672 Thanks for the feedback, I moved the line downwards - I originally placed it higher up as that's where it was for regular sessions, for other sessions it is indeed listed later though, so I guess that will be fine. It does seem to be placed before pam_loginuid though, so that's where I put it.

I really doubt that order matters that much (as long as it comes before the common-session include) but PAM is a bit magic and is one of the things in Linux that had the most amount of surprises. That's why I moved the line to its current position, just in case it matters afterall.

It is in the session-block now, but let me know if you need it elsewhere.
A backport would be really nice indeed, thank you all for the review and generally work on xrdp!

@matt335672 matt335672 requested a review from metalefty December 16, 2024 16:51
@metalefty
Copy link
Member

Approved.

@ximion Thanks for your contribution! This change will be included in the next release planed in this December.

@matt335672 matt335672 merged commit 441f427 into neutrinolabs:devel Dec 17, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants