3

This question already has an answer here:

I work at an organisation where the fileserver containing /home sometimes fails to start in the morning. I can still log in on the console but get an error message something like $HOME not available, using /. In this case my workaround is

cd /tmp
mkdir home
chmod 700 home
export HOME=/tmp/home
# wget a copy of my "emergency" rc files that I keep online
# xinit, twm etc. 

so I can still read e-mails through a web browser and if the file server is down for long, checkout my current projects from gitlab into /tmp and continue there.

Xterm and twm seem to respect $HOME and happily work in my temporary setting, cd with no parameters and ~ in bash work fine. chromium-browser does not and still complains about /home/organisation-specific-stuff/my-username not being available. (Chromium will run with --user-data-dir=/tmp/home/chromium but launching it still causes dbus to throw a fit about non-existent /home).

My questions:

  • What other ways besides $HOME are there for programs to reference the "home directory", and are there good reasons (for example security implications) why some programs choose one over the other?

  • Is there a way to tell e.g. chromium, dbus to temporarily use /tmp/home instead? I cannot use the solution in [1] due to lack of root rights. For the same reason, chroot seems out of the question. Or is this a stupid/dangerous thing to do?

My system is Ubuntu "precise" if that makes a difference.

[1] Temporarily use something else as home directory

marked as duplicate by Gilles 'SO- stop being evil', Ramesh, slm Oct 1 '14 at 2:19

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    As a former twm and xterm user, I feel your pain. Have you looked through the output from the "set" command? (all the environment variables). Does firefox work? Can you run a vnc client, so that you can connect to another machine? What happens if you set USER to a non-existent user? (Just in case chromium looks up the home directory in a file in /etc). And last but not least, have you tried turning it off and on again? – Alexander Sep 30 '14 at 9:51
  • 1
    Many apps will do the equivalent of getent passwd $(whoami) | awk -F: '{ print $6 }'. And short of modifying /etc/passwd, you cannot do anything about it. – Patrick Sep 30 '14 at 12:15
1

Your question intrigues me, and I did not have a ready answer. No Unix, Linux or *BSD I've tried has a system call relating to "home directory". I can't google up anything about the linux kernel knowing a user's home directory. So, I believe that the value of $HOME is the official source of record for a shell to figure out "home directory". The login program sets HOME based on the contents of /etc/passwd when the login program forks and execs a user's shell.

As you've noticed, if the value of $HOME doesn't match the name of a directory, things go a little rough, mainly in the area of shell conveniences, but nothing really breaks outright - you can still mostly use the login shell. I experimented by setting export HOME=/var/tmp. bash doesn't seem to mind that, and cd ~ takes you right to /var/tmp.

Not the answer you're looking for? Browse other questions tagged or ask your own question.