$HOME is for all users /root

Issue:

 $HOME is /root for every user
 although the directory that you enter when you log in, 
even as ldap user is your real homedir as found in ldap 
or /etc/passwd for the local users.
I was unable to find where it is set:
not in 
/etc/profile
/etc/profile.d/*
/etc/bashrc
/etc/bash_completion.d/*

This is an anoying issue on a server that was centos 8 and was upgraded to Rocky Linux 8
I only have this on 1 server that was migrated, many others don’t have it, so I doubt it is due to the upgrade process

This one is only used as printserver and I found out when having trouble upgrading the papercutserver.

The server was originally not set up by me but by a support provider, at least that guy has moved jobs , I can’t trace him for the modif he made,… if it was him and not some other cause.

The puzzle is open for all.

I have a fairly stable workaround:
I added a line to /etc/bashrc:

export HOME=$PWD

I know it is kluge and would rather want to find the real cause and resolve it there.

HOME is normally set by your shell. What does getent passwd shows for your non-root users?

$HOME is set by login for local logins. See man login.

For ssh connections, sshd will set it. Same applies for graphical sessions (e.g. gdm).

This is not a stable workaround. You are defeating the purpose of login/sshd/others. The programs that handle setting those variables are looking at /etc/passwd or NSS to determine how your home directory is set. Ritov asked for getent passwd, so that will tell you (and us) how $HOME is supposed to be set and how to further troubleshoot your issue.

Sure, depending on the entry point as also noted with sshd. More do it - sudo, su

getent passwd dumps /etc/passwd, combined with ldap.
What is returned there is correct, it is the correct homedir for each user, it is also the login dir.
That is why
export HOME=$PWD as last line of
/etc/bashrc
is a workaround.

that would be then
/etc/login.defs
no $HOME defined there

thanks but no solution there yet:
grepped additionally

/etc/login.defs
/etc/pam.d/*
/etc/ssh/*
/etc/ssh/ssh_config.d/*

for -i HOME
no definions of HOME there

grep -i HOME /etc/login.defs
#   home directory.  If you _do_ define both, MAIL_DIR takes precedence.
# home directories if HOME_MODE is not set.
# HOME_MODE is used by useradd(8) and newusers(8) to set the mode for new
# home directories.
# If HOME_MODE is not set, the value of UMASK is used to create the mode.
HOME_MODE	0700
# If useradd should create home directories for users by default
CREATE_HOME	yes
grep -i HOME /etc/pam.d/*
/etc/pam.d/fingerprint-auth:session     optional                                     pam_oddjob_mkhomedir.so umask=0077
/etc/pam.d/password-auth:session     optional                                     pam_oddjob_mkhomedir.so umask=0077
/etc/pam.d/system-auth:session     optional                                     pam_oddjob_mkhomedir.so umask=0077
[root@cups07 ssh]# grep -i HOME /etc/ssh/*
grep: /etc/ssh/ssh_config.d: Is a directory
[root@cups07 ssh]# grep -i HOME /etc/ssh_config.d/*
grep: /etc/ssh_config.d/*: No such file or directory

If login and sshd do set HOME, they might do it in the binary, rather than by sourcing HOME=... from config files. If they set it “wrong”, then where do they get the wrong value from?

If login and sshd do set HOME, they might do it in the binary, rather than by sourcing HOME=… from config files. If they set it “wrong”, then where do they get the wrong value from?

If it would be set by a binary, it should end up in a bugreport quickly, no?
I have the same issue on a server Rocky Linux 8.8 with 388 pending updates and it’s (vmware) clone fully updated to Rocky Linux 8.9 without pending packages.
Interesting question however.

Could you set up a new, “fresh”, printserver and replace the current?
That way you would clear out the unknown modifications.