2

I have a partition on a hard drive that is encrypted with dm-crypt using a passphrase. What I want to do is have a password prompt pop up when some program tries to read a file within this partitions target mount point.

Eg. I normally mount my dm-crypt volume in the directory /mnt/crypt. When mounted, inside this directory is a "Music" folder which has the file goodmusic.mp3 in it. So the path is /mnt/crypt/Music/goodmusic.mp3.

If I start Clementine and try to play this file without the encrypted volume being mounted, I'll get a "file not found" error.

What I want to do is, when Clementine tries to open a file in this directory (/mnt/crypt), have a prompt pop up that asks for my mount password and mounts the volume. I guess, in order for it to work, the "read" syscall needs to block while the password prompt is shown, so that the read syscall won't report back an error immediately, before I've had a chance to type in my passphrase.

Is this possible?

I've been playing with inotify, but it doesn't seem to support events for non-existing files.

migrated from stackoverflow.com Nov 3 '13 at 18:48

This question came from our site for professional and enthusiast programmers.

1

(1)
inotify doesn't report access/read/write attempts on non-existing files.
In fact, they are't treated as events because these files don't exist at all.

(2)

What I want to do is, when Clementine tries to open a file in this directory (/mnt/crypt), have a prompt pop up that asks for my mount password and mounts the volume. I guess, in order for it to work, the "read" syscall needs to block while the password prompt is shown, so that the read syscall won't report back an error immediately, before I've had a chance to type in my passphrase.

It's quite complicated. One possible solution is to hook the glibc's open system call and redefine your own version. Your version of open just acts like what you describe, according to the file/dirctory a process tries to access.

reference:
http://en.wikipedia.org/wiki/Hooking
http://www.gilgalab.com.br/hacking/programming/linux/2013/01/11/Hooking-Linux-3-syscalls/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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