* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
@ 2007-06-06 23:08 ` Kay Sievers
2007-06-07 3:38 ` Andrey Borzenkov
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Kay Sievers @ 2007-06-06 23:08 UTC (permalink / raw)
To: linux-hotplug
On 6/7/07, Farkas Levente <lfarkas@bppiac.hu> wrote:
> hi,
> how can i write a RUN udev rules for remove event? i want to recognize
> my usd pendrive's add and remove. the add is simple since i can use
> rather specific rules like:
> ---------------------------------------
> ACTION="add", SUBSYSTEM="block", ATTR{size}="2880",
> ATTRS{serial}="07530736300A", ATTRS{product}="USB DISK Pro", RUN+="/xxx"
> ---------------------------------------
> but the remove rule is much complicated, since (at least it seems for
> me) udev don't send ATTR(S) in this case and don't know about anymore
> the removed device parameters.
You can't. Sysfs attributes are already gone when you see the remove event.
> anyway how can i how what kind of ATTR(S) was send by udev?
> a simple RUN script like this is not too useful since it's only shows
> environment variable but not ATTR(S)
> -----------------------
> #!/bin/bash
> OUT=/tmp/udev.$$
> echo " ------ $ACTION ------------" > $OUT
> set >> $OUT
> -----------------------
> is there any way to debug udev?
ATTR matches files in sysfs, they are not part of the event.
> another question what is the ID_* env variables? these are the same as
> ATTR(S) or ..?
No, ATTR are files in /sys/*, ID_* variable are added to the event
environment by udev tools.
Play around with:
udevmonitor
and:
udevmonitor --env
while connecting a device.
And try:
udevtest <devpath>
and it will probably become more clear.
Kay
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
2007-06-06 23:08 ` Kay Sievers
@ 2007-06-07 3:38 ` Andrey Borzenkov
2007-06-07 8:38 ` Farkas Levente
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andrey Borzenkov @ 2007-06-07 3:38 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 844 bytes --]
> On 6/7/07, Farkas Levente <lfarkas@bppiac.hu> wrote:
> > hi,
> > how can i write a RUN udev rules for remove event? i want to recognize
> > my usd pendrive's add and remove. the add is simple since i can use
> > rather specific rules like:
> > ---------------------------------------
> > ACTION=="add", SUBSYSTEM=="block", ATTR{size}=="2880",
> > ATTRS{serial}=="07530736300A", ATTRS{product}=="USB DISK Pro",
> > RUN+="/xxx" ---------------------------------------
> > but the remove rule is much complicated, since (at least it seems for
> > me) udev don't send ATTR(S) in this case and don't know about anymore
> > the removed device parameters.
>
If you absolutely need them on remove (could you explain why? What exactly are
you trying to do?), set environment vars on add and use (match) them on
remove.
-andrey
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
2007-06-06 23:08 ` Kay Sievers
2007-06-07 3:38 ` Andrey Borzenkov
@ 2007-06-07 8:38 ` Farkas Levente
2007-06-07 16:30 ` Andrey Borzenkov
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Farkas Levente @ 2007-06-07 8:38 UTC (permalink / raw)
To: linux-hotplug
Andrey Borzenkov wrote:
>> On 6/7/07, Farkas Levente <lfarkas@bppiac.hu> wrote:
>>> hi,
>>> how can i write a RUN udev rules for remove event? i want to recognize
>>> my usd pendrive's add and remove. the add is simple since i can use
>>> rather specific rules like:
>>> ---------------------------------------
>>> ACTION="add", SUBSYSTEM="block", ATTR{size}="2880",
>>> ATTRS{serial}="07530736300A", ATTRS{product}="USB DISK Pro",
>>> RUN+="/xxx" ---------------------------------------
>>> but the remove rule is much complicated, since (at least it seems for
>>> me) udev don't send ATTR(S) in this case and don't know about anymore
>>> the removed device parameters.
>
> If you absolutely need them on remove (could you explain why? What exactly are
> you trying to do?), set environment vars on add and use (match) them on
> remove.
ok so what i really need to somehow properly identify my pen drive. my
home partition is luks encrypted and the key on on my pen drive. when i
pug in the pen, udev recognize it and mount (after luksopen) the
encrypted volue as /home/lfarkas. when i finish my work, simple logout
and remove the pen. udev recognize the remove and umount (and luksclose)
the volume. what i want to avoid to confuse my pen with other usb device
eg. camera, pda and other pen device.
ps. anyway this has been working for years, but now as i upgrade to
fedora 7 and have to rewrite the rules (because of the SYSFS<->ATTR
changes) i'd also like to polish my scripts.
--
Levente "Si vis pacem para bellum!"
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (2 preceding siblings ...)
2007-06-07 8:38 ` Farkas Levente
@ 2007-06-07 16:30 ` Andrey Borzenkov
2007-06-07 21:13 ` Farkas Levente
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andrey Borzenkov @ 2007-06-07 16:30 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 395 bytes --]
On Thursday 07 June 2007, Farkas Levente wrote:
> ok so what i really need to somehow properly identify my pen drive. my
> home partition is luks encrypted and the key on on my pen drive. when i
> pug in the pen, udev recognize it and mount
Any reason you are not using HAL for this? udev is simply the wrong place to
do such things. And HAL supports LUKS natively AFAIR.
-andrey
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (3 preceding siblings ...)
2007-06-07 16:30 ` Andrey Borzenkov
@ 2007-06-07 21:13 ` Farkas Levente
2007-06-09 13:03 ` Farkas Levente
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Farkas Levente @ 2007-06-07 21:13 UTC (permalink / raw)
To: linux-hotplug
Andrey Borzenkov wrote:
> On Thursday 07 June 2007, Farkas Levente wrote:
>> ok so what i really need to somehow properly identify my pen drive. my
>> home partition is luks encrypted and the key on on my pen drive. when i
>> pug in the pen, udev recognize it and mount
>
>
> Any reason you are not using HAL for this? udev is simply the wrong place to
> do such things. And HAL supports LUKS natively AFAIR.
i don't see how can i use hal here? would you explain it to me?!
anyway luks supported by the kernel natively hal has nothing to do with it.
--
Levente "Si vis pacem para bellum!"
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (4 preceding siblings ...)
2007-06-07 21:13 ` Farkas Levente
@ 2007-06-09 13:03 ` Farkas Levente
2007-06-09 15:37 ` Andrey Borzenkov
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Farkas Levente @ 2007-06-09 13:03 UTC (permalink / raw)
To: linux-hotplug
Andrey Borzenkov wrote:
>> On 6/7/07, Farkas Levente <lfarkas@bppiac.hu> wrote:
>>> hi,
>>> how can i write a RUN udev rules for remove event? i want to recognize
>>> my usd pendrive's add and remove. the add is simple since i can use
>>> rather specific rules like:
>>> ---------------------------------------
>>> ACTION="add", SUBSYSTEM="block", ATTR{size}="2880",
>>> ATTRS{serial}="07530736300A", ATTRS{product}="USB DISK Pro",
>>> RUN+="/xxx" ---------------------------------------
>>> but the remove rule is much complicated, since (at least it seems for
>>> me) udev don't send ATTR(S) in this case and don't know about anymore
>>> the removed device parameters.
>
> If you absolutely need them on remove (could you explain why? What exactly are
> you trying to do?), set environment vars on add and use (match) them on
> remove.
how can i do so?
eg i create a new link SYMLINK+="lfarkas" in the add action
and in this case in remove actions env contains
DEVLINKS='/dev/lfarkas /dev/...'
BUT a rule like this:
ACTION="remove", SUBSYSTEM="block", ENV{DEVLINKS}="/dev/lfarkas*"
never match, while a rule like this
ACTION="remove", SUBSYSTEM="block", DEVLINKS="/dev/lfarkas*",
match for all block device.
so how can i match for DEVLINKS?
or what other methods exists for properly identify a removed device?
thanks in advance.
--
Levente "Si vis pacem para bellum!"
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (5 preceding siblings ...)
2007-06-09 13:03 ` Farkas Levente
@ 2007-06-09 15:37 ` Andrey Borzenkov
2007-06-09 15:40 ` Andrey Borzenkov
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andrey Borzenkov @ 2007-06-09 15:37 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 1800 bytes --]
On Saturday 09 June 2007, Farkas Levente wrote:
> Andrey Borzenkov wrote:
> >> On 6/7/07, Farkas Levente <lfarkas@bppiac.hu> wrote:
> >>> hi,
> >>> how can i write a RUN udev rules for remove event? i want to recognize
> >>> my usd pendrive's add and remove. the add is simple since i can use
> >>> rather specific rules like:
> >>> ---------------------------------------
> >>> ACTION=="add", SUBSYSTEM=="block", ATTR{size}=="2880",
> >>> ATTRS{serial}=="07530736300A", ATTRS{product}=="USB DISK Pro",
> >>> RUN+="/xxx" ---------------------------------------
> >>> but the remove rule is much complicated, since (at least it seems for
> >>> me) udev don't send ATTR(S) in this case and don't know about anymore
> >>> the removed device parameters.
> >
> > If you absolutely need them on remove (could you explain why? What
> > exactly are you trying to do?), set environment vars on add and use
> > (match) them on remove.
>
> how can i do so?
just like you did. ENV{foo}="bar" on add.
> eg i create a new link SYMLINK+="lfarkas" in the add action
> and in this case in remove actions env contains
> DEVLINKS='/dev/lfarkas /dev/...'
> BUT a rule like this:
> ACTION=="remove", SUBSYSTEM=="block", ENV{DEVLINKS}=="/dev/lfarkas*"
> never match,
Because DEVLINKS does not come from persistent environment. Check with
udevinfo --query=env.
> so how can i match for DEVLINKS?
well, again, are you sure you really need it? What do you try to do?
> or what other methods exists for properly identify a removed device?
Device is identified by DEVPATH. If you mean - you need to fetch special
device attributes that you had set during device add event - you can either
store them as environment variable or implement your own on-disk persistent
store.
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (6 preceding siblings ...)
2007-06-09 15:37 ` Andrey Borzenkov
@ 2007-06-09 15:40 ` Andrey Borzenkov
2007-06-09 17:54 ` Kay Sievers
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andrey Borzenkov @ 2007-06-09 15:40 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 986 bytes --]
On Friday 08 June 2007, Farkas Levente wrote:
> Andrey Borzenkov wrote:
> > On Thursday 07 June 2007, Farkas Levente wrote:
> >> ok so what i really need to somehow properly identify my pen drive. my
> >> home partition is luks encrypted and the key on on my pen drive. when i
> >> pug in the pen, udev recognize it and mount
> >
> > Any reason you are not using HAL for this? udev is simply the wrong place
> > to do such things. And HAL supports LUKS natively AFAIR.
>
> i don't see how can i use hal here? would you explain it to me?!
>
you never mentioned before that you want to mount encrypted partition when you
are ot logged on. I am not sure how it works (you need to enter you key at
some point, do not you?) but you can use something like ivman or write
trivial handler in python that listens to device insert events and mounts
them via HAL API.
> anyway luks supported by the kernel natively hal has nothing to do with it.
as well as udev :)
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (7 preceding siblings ...)
2007-06-09 15:40 ` Andrey Borzenkov
@ 2007-06-09 17:54 ` Kay Sievers
2007-06-09 19:58 ` Farkas Levente
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Kay Sievers @ 2007-06-09 17:54 UTC (permalink / raw)
To: linux-hotplug
On 6/9/07, Andrey Borzenkov <arvidjaar@mail.ru> wrote:
> On Friday 08 June 2007, Farkas Levente wrote:
> > Andrey Borzenkov wrote:
> > > On Thursday 07 June 2007, Farkas Levente wrote:
> > >> ok so what i really need to somehow properly identify my pen drive. my
> > >> home partition is luks encrypted and the key on on my pen drive. when i
> > >> pug in the pen, udev recognize it and mount
> > >
> > > Any reason you are not using HAL for this? udev is simply the wrong place
> > > to do such things. And HAL supports LUKS natively AFAIR.
> >
> > i don't see how can i use hal here? would you explain it to me?!
> >
>
> you never mentioned before that you want to mount encrypted partition when you
> are ot logged on. I am not sure how it works (you need to enter you key at
> some point, do not you?) but you can use something like ivman or write
> trivial handler in python that listens to device insert events and mounts
> them via HAL API.
Right, HAL already handles teardown of LUKS volumes when they are removed.
> > anyway luks supported by the kernel natively hal has nothing to do with it.
>
> as well as udev :)
That's true. :)
Thanks,
Kay
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (8 preceding siblings ...)
2007-06-09 17:54 ` Kay Sievers
@ 2007-06-09 19:58 ` Farkas Levente
2007-06-09 20:16 ` Farkas Levente
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Farkas Levente @ 2007-06-09 19:58 UTC (permalink / raw)
To: linux-hotplug
Kay Sievers wrote:
> On 6/9/07, Andrey Borzenkov <arvidjaar@mail.ru> wrote:
>> On Friday 08 June 2007, Farkas Levente wrote:
>>> Andrey Borzenkov wrote:
>>>> On Thursday 07 June 2007, Farkas Levente wrote:
>>>>> ok so what i really need to somehow properly identify my pen drive. my
>>>>> home partition is luks encrypted and the key on on my pen drive. when i
>>>>> pug in the pen, udev recognize it and mount
>>>> Any reason you are not using HAL for this? udev is simply the wrong place
>>>> to do such things. And HAL supports LUKS natively AFAIR.
>>> i don't see how can i use hal here? would you explain it to me?!
>>>
>> you never mentioned before that you want to mount encrypted partition when you
>> are ot logged on. I am not sure how it works (you need to enter you key at
>> some point, do not you?) but you can use something like ivman or write
>> trivial handler in python that listens to device insert events and mounts
>> them via HAL API.
>
> Right, HAL already handles teardown of LUKS volumes when they are removed.
my luks partition is on the hard drive it's a 40GB lvm partition. the
encryption key to the partition is on the pen drive. and i'd like to
automatically luksopen and mount the encrypted partition when i plug in
my pendrive and umount and luksclose when i unplug the pendrive.
--
Levente "Si vis pacem para bellum!"
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (9 preceding siblings ...)
2007-06-09 19:58 ` Farkas Levente
@ 2007-06-09 20:16 ` Farkas Levente
2007-06-10 4:18 ` Andrey Borzenkov
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Farkas Levente @ 2007-06-09 20:16 UTC (permalink / raw)
To: linux-hotplug
Andrey Borzenkov wrote:
> On Friday 08 June 2007, Farkas Levente wrote:
>> Andrey Borzenkov wrote:
>>> On Thursday 07 June 2007, Farkas Levente wrote:
>>>> ok so what i really need to somehow properly identify my pen drive. my
>>>> home partition is luks encrypted and the key on on my pen drive. when i
>>>> pug in the pen, udev recognize it and mount
>>> Any reason you are not using HAL for this? udev is simply the wrong place
>>> to do such things. And HAL supports LUKS natively AFAIR.
>> i don't see how can i use hal here? would you explain it to me?!
>>
>
> you never mentioned before that you want to mount encrypted partition when you
> are ot logged on. I am not sure how it works (you need to enter you key at
> some point, do not you?) but you can use something like ivman or write
> trivial handler in python that listens to device insert events and mounts
> them via HAL API.
my home directory is a luks encrypted volume:
----------------------------------------
# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
34692928 5613204 27288956 18% /
/dev/sda1 101086 12297 83570 13% /boot
tmpfs 517532 0 517532 0% /dev/shm
/dev/mapper/home-lfarkas
39509616 27716680 11391540 71% /home/lfarkas
# cryptsetup status home-lfarkas
/dev/mapper/home-lfarkas is active:
cipher: twofish-cbc-essiv:sha256
keysize: 256 bits
device: /dev/mapper/VolGroup00-LogVol02
offset: 2056 sectors
size: 80279544 sectors
mode: read/write
----------------------------------------
the keyfile (ie. the password to the encrypted partition) is on the
pendrive hidden partition. _before_ i login i just plug in the pendrive
and udev recognize it and mount the pendrive and use the file which
contains the encryption key and mount my volume. this's my udev rules:
----------------------------------------
# cat /etc/udev/rules.d/10-local.rules
ACTION="add", KERNEL="sd[a-z]", SUBSYSTEM="block",
ATTR{size}="2880", ATTRS{serial}="07530736300A", ATTRS{product}="USB
DISK Pro", SYMLINK+="lfarkas", RUN+="/root/bin/home-up
/dev/VolGroup00/LogVol02 lfarkas"
ACTION="remove", KERNEL="sd[a-z]", SUBSYSTEM="block",
RUN+="/root/bin/home-down lfarkas"
----------------------------------------
and the used scripts:
----------------------------------------
# cat /root/bin/home-up
#!/bin/bash
if [ -z "`grep /home/$2 /proc/mounts`" ]; then
TMPDEV="/mnt/tmp"
mount -t vfat $DEVNAME $TMPDEV
KEY="$TMPDEV/.$2.key"
if [ ! -f $KEY ]; then
exit 1
fi
/root/bin/luks-up $1 /home/$2 < $KEY
RES=$?
umount $TMPDEV
exit $RES
fi
# cat /root/bin/home-down
#!/bin/bash
if [ -z "`ps -u $1|grep .Xclients|egrep -v grep`" ]; then
killall -u $1
umount /media/*
sleep 5
/root/bin/luks-down /home/$1
fi
----------------------------------------
this's working. the only problem i'd like to do it better ie somehow
recognize only _my_ pendrive. in case of add i can use ATTR{size},
ATTRS{serial}, ATTRS{product}, but in remove i can't do any better then
KERNEL="sd[a-z]", SUBSYSTEM="block" which is a satisfied by all kind
of removable device:-( so that's my problem. ie if i plug and remove my
camera it also try to remove my home partition:-(
i hope it's clear now.
--
Levente "Si vis pacem para bellum!"
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (10 preceding siblings ...)
2007-06-09 20:16 ` Farkas Levente
@ 2007-06-10 4:18 ` Andrey Borzenkov
2007-06-10 11:33 ` Farkas Levente
2007-06-10 11:38 ` Andrey Borzenkov
13 siblings, 0 replies; 15+ messages in thread
From: Andrey Borzenkov @ 2007-06-10 4:18 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 3516 bytes --]
On Sunday 10 June 2007, Farkas Levente wrote:
> Andrey Borzenkov wrote:
> > On Friday 08 June 2007, Farkas Levente wrote:
> >> Andrey Borzenkov wrote:
> >>> On Thursday 07 June 2007, Farkas Levente wrote:
> >>>> ok so what i really need to somehow properly identify my pen drive. my
> >>>> home partition is luks encrypted and the key on on my pen drive. when
> >>>> i pug in the pen, udev recognize it and mount
> >>>
> >>> Any reason you are not using HAL for this? udev is simply the wrong
> >>> place to do such things. And HAL supports LUKS natively AFAIR.
> >>
> >> i don't see how can i use hal here? would you explain it to me?!
> >
> > you never mentioned before that you want to mount encrypted partition
> > when you are ot logged on. I am not sure how it works (you need to enter
> > you key at some point, do not you?) but you can use something like ivman
> > or write trivial handler in python that listens to device insert events
> > and mounts them via HAL API.
>
> my home directory is a luks encrypted volume:
OK
> ----------------------------------------
> # df
> Filesystem 1K-blocks Used Available Use% Mounted on
> /dev/mapper/VolGroup00-LogVol00
> 34692928 5613204 27288956 18% /
> /dev/sda1 101086 12297 83570 13% /boot
> tmpfs 517532 0 517532 0% /dev/shm
> /dev/mapper/home-lfarkas
> 39509616 27716680 11391540 71% /home/lfarkas
> # cryptsetup status home-lfarkas
> /dev/mapper/home-lfarkas is active:
> cipher: twofish-cbc-essiv:sha256
> keysize: 256 bits
> device: /dev/mapper/VolGroup00-LogVol02
> offset: 2056 sectors
> size: 80279544 sectors
> mode: read/write
> ----------------------------------------
> the keyfile (ie. the password to the encrypted partition) is on the
> pendrive hidden partition. _before_ i login i just plug in the pendrive
> and udev recognize it and mount the pendrive and use the file which
> contains the encryption key and mount my volume.
Yes, I guess as it stands now, HAL is not capable of doing it (even when user
is logged on). I guess it makes sense to forward this full description to
HAL list for discussion.
> this's my udev rules:
> ----------------------------------------
> # cat /etc/udev/rules.d/10-local.rules
> ACTION=="add", KERNEL=="sd[a-z]", SUBSYSTEM=="block",
> ATTR{size}=="2880", ATTRS{serial}=="07530736300A", ATTRS{product}=="USB
> DISK Pro", SYMLINK+="lfarkas", RUN+="/root/bin/home-up
> /dev/VolGroup00/LogVol02 lfarkas"
>
> ACTION=="remove", KERNEL=="sd[a-z]", SUBSYSTEM=="block",
> RUN+="/root/bin/home-down lfarkas"
[...]
> this's working. the only problem i'd like to do it better ie somehow
> recognize only _my_ pendrive. in case of add i can use ATTR{size},
> ATTRS{serial}, ATTRS{product}, but in remove i can't do any better then
> KERNEL=="sd[a-z]", SUBSYSTEM=="block" which is a satisfied by all kind
> of removable device:-( so that's my problem. ie if i plug and remove my
> camera it also try to remove my home partition:-(
Have you ever tried udevinfo?
{pts/0}% udevinfo -q env --name sda
ID_VENDOR=ATA
ID_MODEL=IC25N020ATDA04-0
ID_REVISION=DA3O
ID_SERIAL=SATA_IC25N020ATDA04-_63A63GY1081
ID_SERIAL_SHORT=63A63GY1081
ID_TYPE=disk
ID_BUS=scsi
ID_ATA_COMPAT=IC25N020ATDA04-0_63A63GY1081
ID_PATH=pci-0000:00:04.0-scsi-0:0:0:0
ID_EDD=int13_dev80
notice ID_SERIAL or ID_SERIAL_SHORT?
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (11 preceding siblings ...)
2007-06-10 4:18 ` Andrey Borzenkov
@ 2007-06-10 11:33 ` Farkas Levente
2007-06-10 11:38 ` Andrey Borzenkov
13 siblings, 0 replies; 15+ messages in thread
From: Farkas Levente @ 2007-06-10 11:33 UTC (permalink / raw)
To: linux-hotplug
Andrey Borzenkov wrote:
>> this's my udev rules:
>> ----------------------------------------
>> # cat /etc/udev/rules.d/10-local.rules
>> ACTION="add", KERNEL="sd[a-z]", SUBSYSTEM="block",
>> ATTR{size}="2880", ATTRS{serial}="07530736300A", ATTRS{product}="USB
>> DISK Pro", SYMLINK+="lfarkas", RUN+="/root/bin/home-up
>> /dev/VolGroup00/LogVol02 lfarkas"
>>
>> ACTION="remove", KERNEL="sd[a-z]", SUBSYSTEM="block",
>> RUN+="/root/bin/home-down lfarkas"
> [...]
>> this's working. the only problem i'd like to do it better ie somehow
>> recognize only _my_ pendrive. in case of add i can use ATTR{size},
>> ATTRS{serial}, ATTRS{product}, but in remove i can't do any better then
>> KERNEL="sd[a-z]", SUBSYSTEM="block" which is a satisfied by all kind
>> of removable device:-( so that's my problem. ie if i plug and remove my
>> camera it also try to remove my home partition:-(
>
> Have you ever tried udevinfo?
>
> {pts/0}% udevinfo -q env --name sda
> ID_VENDOR=ATA
> ID_MODEL=IC25N020ATDA04-0
> ID_REVISIONÚ3O
> ID_SERIAL=SATA_IC25N020ATDA04-_63A63GY1081
> ID_SERIAL_SHORTcA63GY1081
> ID_TYPE=disk
> ID_BUS=scsi
> ID_ATA_COMPAT=IC25N020ATDA04-0_63A63GY1081
> ID_PATH=pci-0000:00:04.0-scsi-0:0:0:0
> ID_EDD=int13_dev80
>
> notice ID_SERIAL or ID_SERIAL_SHORT?
yes but as i wrote earlier if i write
ENV{ID_SERIAL}="_USB_DISK_Pro_07530736300A" it's not working in case of
removal! that's my problem!
--
Levente "Si vis pacem para bellum!"
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread* Re: udev remove ATTR(S) not working
2007-06-06 22:56 udev remove ATTR(S) not working Farkas Levente
` (12 preceding siblings ...)
2007-06-10 11:33 ` Farkas Levente
@ 2007-06-10 11:38 ` Andrey Borzenkov
13 siblings, 0 replies; 15+ messages in thread
From: Andrey Borzenkov @ 2007-06-10 11:38 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 1747 bytes --]
On Sunday 10 June 2007, Farkas Levente wrote:
> Andrey Borzenkov wrote:
> >> this's my udev rules:
> >> ----------------------------------------
> >> # cat /etc/udev/rules.d/10-local.rules
> >> ACTION=="add", KERNEL=="sd[a-z]", SUBSYSTEM=="block",
> >> ATTR{size}=="2880", ATTRS{serial}=="07530736300A", ATTRS{product}=="USB
> >> DISK Pro", SYMLINK+="lfarkas", RUN+="/root/bin/home-up
> >> /dev/VolGroup00/LogVol02 lfarkas"
> >>
> >> ACTION=="remove", KERNEL=="sd[a-z]", SUBSYSTEM=="block",
> >> RUN+="/root/bin/home-down lfarkas"
> >
> > [...]
> >
> >> this's working. the only problem i'd like to do it better ie somehow
> >> recognize only _my_ pendrive. in case of add i can use ATTR{size},
> >> ATTRS{serial}, ATTRS{product}, but in remove i can't do any better then
> >> KERNEL=="sd[a-z]", SUBSYSTEM=="block" which is a satisfied by all kind
> >> of removable device:-( so that's my problem. ie if i plug and remove my
> >> camera it also try to remove my home partition:-(
> >
> > Have you ever tried udevinfo?
> >
> > {pts/0}% udevinfo -q env --name sda
> > ID_VENDOR=ATA
> > ID_MODEL=IC25N020ATDA04-0
> > ID_REVISION=DA3O
> > ID_SERIAL=SATA_IC25N020ATDA04-_63A63GY1081
> > ID_SERIAL_SHORT=63A63GY1081
> > ID_TYPE=disk
> > ID_BUS=scsi
> > ID_ATA_COMPAT=IC25N020ATDA04-0_63A63GY1081
> > ID_PATH=pci-0000:00:04.0-scsi-0:0:0:0
> > ID_EDD=int13_dev80
> >
> > notice ID_SERIAL or ID_SERIAL_SHORT?
>
> yes but as i wrote earlier if i write
> ENV{ID_SERIAL}="_USB_DISK_Pro_07530736300A" it's not working in case of
> removal! that's my problem!
no, earlier you wrote you tried ENV{DEVLINKS} which is not going to work. And
if you really use the above, it won't work either - you have to use == not =
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
[-- Attachment #2: Type: text/plain, Size: 286 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
[-- Attachment #3: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 15+ messages in thread