You are not logged in.

#1 2012-10-19 19:47:47

Jonhoo
Member
Registered: 2009-05-23
Posts: 113

remounting home directory in .xinitrc

Hey!

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..

Cheers,
Jon

Offline

#2 2012-10-19 21:29:50

dammannj
Member
Registered: 2009-01-28
Posts: 44

Re: remounting home directory in .xinitrc

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?

Offline

#3 2012-10-19 22:37:24

Jonhoo
Member
Registered: 2009-05-23
Posts: 113

Re: remounting home directory in .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 smile

Offline

#4 2012-10-20 13:56:10

Jonhoo
Member
Registered: 2009-05-23
Posts: 113

Re: remounting home directory in .xinitrc

Yup, that did the trick!

Everything now seems to be in order, so I've created the package in the AUR.
It is available here: https://aur.archlinux.org/packages.php?ID=63776

Offline

Board footer

Powered by FluxBB