Skip to content

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

Merged
robert-ancell merged 3 commits into
ubuntu:mainfrom
gber:main
Mar 19, 2024
Merged

Add support for changing the home directory in PAM modules#323
robert-ancell merged 3 commits into
ubuntu:mainfrom
gber:main

Conversation

@gber

@gber gber commented Sep 21, 2023

Copy link
Copy Markdown

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.

@robert-ancell robert-ancell left a comment

Copy link
Copy Markdown
Collaborator

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?

Comment thread src/session-child.c
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

gber commented Oct 9, 2023

Copy link
Copy Markdown
Author

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
Copy Markdown

@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!

@robert-ancell robert-ancell left a comment

Copy link
Copy Markdown
Collaborator

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 ubuntu:main Mar 19, 2024
@JPeisach JPeisach added this to the 1.33.0 milestone Aug 2, 2026
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

4 participants