]> git.ipfire.org Git - thirdparty/util-linux.git/commit
login: actually honour $HOME for chdir()
authorLennart Poettering <lennart@poettering.net>
Thu, 9 Jan 2025 22:57:32 +0000 (23:57 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 13 Jan 2025 17:08:06 +0000 (18:08 +0100)
commit2e269ff4bc32cb61e1d576d4f932b4027f5bc2c8
treef7308adb1a9f9d46456dd162a93ba0d32c599071
parentb4ea6459da5767de34fde33c5e2751788203b989
login: actually honour $HOME for chdir()

When login is almost done it chdir()'s into the user's home directory.
It currently uses pwd->pw_dir, i.e the home dir actually assigned to the
user.

OTOH it explicitly allows overriding HOME (see comment in
init_environ()), and explicitly imports PAM's env vars (which quite
possibly contain $HOME) into its env block.

This patch makes sure that HOME is *properly* overridable via the env
var and via PAM: it actually honours it for the chdir().

(Background: I am working on a PAM module that under some conditions
would like to redirect the home dir to some other dir, and while I can
nicely set $HOME from the PAM module, it has not as much as effect as I
wish, because whie the rest of userspace respects it login so far didn't
and leaves the user in the wrong dir).
include/logindefs.h
lib/logindefs.c
login-utils/login.c
login-utils/lslogins.c