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

Add support for changing the home directory in PAM modules #323

Merged
merged 3 commits into from
Mar 19, 2024

Conversation

gber
Copy link

@gber gber commented Sep 21, 2023

PAM modules such as pam_mklocaluser may change or even create the home directory. Currently, LightDM assumes that the home directory will not change when opening the PAM session, the user's home directory is obtained via getpwent() after authentication but before opening the session. Fix this by trying to update the user's home directory from the HOME environment variable from PAM after opening the session.
Furthermore, if the Xauthority file is not stored in a system directory, the daemon hardcodes its path to the user's home directory and passes it as an absolute path to the session child. Fix this by passing it as a relative path so that the actual path can be constructed after the PAM session has been opened and the home directory has potentially been updated.

This fixes #322.

Copy link
Collaborator

@robert-ancell robert-ancell left a comment

Choose a reason for hiding this comment

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

This looks generally good. I think we'd want to return the home directory in the "Report authentication result" section in session-child.c so other code can access it (i.e. in the same way the username is returned).

It really should have a test in tests/, could you have a go at one?

src/session-child.c Show resolved Hide resolved
Guido Berhoerster added 3 commits October 9, 2023 13:58
PAM modules such as pam_mklocaluser may change or even create the home
directory. Currently, LightDM assumes that the home directory will not change
when opening the PAM session, the user's home directory is obtained via
getpwent() after authentication but before opening the session.  Fix this by
trying to update the user's home directory from the HOME environment variable
from PAM after opening the session.
Furthermore, if the Xauthority file is not stored in a system directory, the
daemon hardcodes its path to the user's home directory and passes it as an
absolute path to the session child.  Fix this by passing it as a relative path
so that the actual path can be constructed after the PAM session has been
opened and the home directory has potentially been updated.
…n child

Return the home directory from the session child to the daemon which may have
been changed by PAM.
Use the returned home directory in the daemon when running script
hooks.
@gber
Copy link
Author

gber commented Oct 9, 2023

This looks generally good. I think we'd want to return the home directory in the "Report authentication result" section in session-child.c so other code can access it (i.e. in the same way the username is returned).

OK, I'm now passing it back and storing in the Session object. I've also versioned the change, please check whether it is correct like this.

I've also modified the script hooks running in the context of the user to use the home directory passed back to the daemon.

It really should have a test in tests/, could you have a go at one?

I have added a test case.

@sunweaver
Copy link

@robert-ancell I checked the status of this PR today and noticed that a second review iteration is necessary. I'd really love to see this patch land in Debian soon, but for this we need upstream approval. Can you take a second look? Thanks!

Copy link
Collaborator

@robert-ancell robert-ancell left a comment

Choose a reason for hiding this comment

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

Thanks!

@robert-ancell robert-ancell merged commit 7367300 into canonical:main Mar 19, 2024
1 check 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.

LightDM should support PAM modules which change the home directory
3 participants