You are not logged in.

#1 2007-10-02 13:37:29

kamituel
Member
From: Poland
Registered: 2006-09-14
Posts: 47
Website

Calling shell script from udev rule

Hello,
I've encrypted partition with key stored on usb drive. I created udev rule:

SYSFS{size}=="....", SYSFS{serial}=="....", ACTION=="add", SYMLINK+="pendrive", RUN=="/bin/sh /home/kamil/bin/cryptsetup.sh"

as You can see I would like to call cryptsetup.sh when pendrive has been inserted. This script looks like:

/bin/mount /media/pendrive
/usr/sbin/cryptsetup luksOpen /dev/sda7 enc1 -d /media/pendrive/key.txt
/bin/mount /mnt/enc1

The idea is to create /dev/mapper/enc1 and mount it automatically without any user action. My problem is that second line of this script (cryptsetup command) hangs for a long time - minute or two.

Here, if it helps, is the listing of processess when cryptsetup hangs:

ps ax | grep crypt
 1379 ?        S<     0:00 [kcryptd/0]
 6418 ?        S<     0:00 [kcryptd/1]
 8046 ?        S<     0:00 /usr/bin/perl /home/kamil/bin/cryptsetup.sh
 8049 ?        S<L    0:01 /usr/sbin/cryptsetup luksOpen /dev/sda8 enc2 -d /media/pendrive/key.txt
 8098 pts/2    S+     0:00 grep crypt

Notice status of command /usr/bin/cryptsetup... - it's S<L. I don't know if it is connected to the problem.
When I comment out this udev rule, connect the pendrive and than manually call cryptsetup.sh I have no problem and everything works fine.

Any ideas how to fix that?
Thanks, best regards
Kamil


I tried, I failed, no matter. Try again, fail again, fail better.

Offline

Board footer

Powered by FluxBB