LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   launch password prompt UI upon insertion of any USB device(udev) (http://www.linuxquestions.org/questions/programming-9/launch-password-prompt-ui-upon-insertion-of-any-usb-device-udev-946409/)

amboxer21 05-23-2012 01:01 AM

launch password prompt UI upon insertion of any USB device(udev)
 
So, I'm getting really bored and want to do another project. So, the idea is that if someone plugs in a usb device, it will launch a UI password prompt. If the password is correct, then allow the device. I have come to understand that I need to use udev for this.

So, how would I go about doing this with udev?

If plug in device > launch UI > if password is correct set rule to allow. If password is wrong > set udev to block.

I probably want to start by permanantly assigning the devices, to specific blocks. Just for starters, no?

Thoughts? Ideas? Feed back?

jhwilliams 05-23-2012 07:06 PM

Checkout the PROGRAM directive in udev(7) man page; it allows for executing external programs on certain events.

Once you have that, you can kick off an auth program (in a GTK frontend.) If auth fails, you return an error code, and udev won't continue.

Still a lot of details to fill in, but there's a path for you to explore, anyway.

amboxer21 05-23-2012 07:36 PM

Yeah I haven't started yet becuae I am still trying to come up with a good approach. ...Still. The UI won't be a problem, the rest will be a piece of cake! It's just the udev events that's the puzzle. Ill have a look at udev(7) in a few, after I eat.

I appreciate the feed back and suggestions @jhwilliams. Thanks.

amboxer21 05-23-2012 09:02 PM

unnecessary post.

amboxer21 05-24-2012 05:46 PM

So I have figured out how to apply an event to all usb devices, with:
Code:

KERNEL=="sd??", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/path/to/script.sh"
As well as monitor the udev daemon in real time, with:
Code:

udevadm monitor --env
I am using
Code:

udevadm monitor --env | grep "VENDOR"
Only because I am going to use the output to mount and umount devices in a script.

I figured I would post this just in case some one else is trying to achieve the same; Generalize udev rules instead of being restricted to only one device. There is not much documentation on this and for what exists, it is useless or crappy. It took me a day and a half to get this far. Horrible right?

On to my script and UI now.
Regards.


All times are GMT -5. The time now is 11:44 AM.