I'm developing a small application that allows me to unencrypt my home partition on login, rather than during boot.
To give you a brief overview of how this works:
1. I add noauto to both crypttab and fstab for my home partition
2. With the home partition unmounted, I create /home/<user>/.xinitrc which contains:
cp ~/.Xauthority /tmp/.xx /usr/local/bin/cryptsetup-gui chome sleep 1 mv /tmp/.xx ~/.Xauthority exec ~/.xinitrc
3. Upon running startx, this file is executed, and cryptsetup-gui is called
4. cryptestup-gui parses /etc/crypttab for the entry named chome, spawns a GTK password entry box and unlocks+mounts the home partition to /home
5. The last line in the unmounted .xinitrc executes the "real" .xinitrc
It works pretty well, with one exception. The location of my home directory seems to somehow be cached. For example, observe this rather odd behaviour:
# Straight after starting a new shell [20:44] jon@x1c ~ $ ls [20:44] jon@x1c ~ $ cd [20:44] jon@x1c ~ $ ls backgrounds bin configs Desktop dev Downloads Dropbox keys src uni
So, in other words, by home directory is not the same as my home directory... My guess is that something, somewhere is storing my home directory by its inode on disk, whereas any script that is run which refers to ~ resolves the path before accessing it, thus reaching the new home directory.
My question is thus; is there any way of preventing this behaviour or otherwise notifying the system to refresh the location of ~?
Hope someone can give me a hand here..
My guess is the following:
Each process has the attribute "working directory", same as it has for example, user and group membership.
This is transfered to child processes.
When you start your program, the working directory is your "unmounted" home, and your programs will start with working directory set to your old home, as well.
Why don't you just put a "cd" in your .xinitrc?
You're probably completely correct.
I'll try it out tomorrow, and if everything works the way it should, I'll probably post the source for the cryptsetup-gui program online and publish a PKGBUILD