LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 05-23-2012, 02:01 AM   #1
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Rep: Reputation: Disabled
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?

Last edited by amboxer21; 05-24-2012 at 07:23 PM.
 
Old 05-23-2012, 08:06 PM   #2
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 208Reputation: 208Reputation: 208
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.
 
Old 05-23-2012, 08:36 PM   #3
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Original Poster
Rep: Reputation: Disabled
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.

Last edited by amboxer21; 05-23-2012 at 08:37 PM.
 
Old 05-23-2012, 10:02 PM   #4
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Original Poster
Rep: Reputation: Disabled
unnecessary post.

Last edited by amboxer21; 05-24-2012 at 06:50 PM. Reason: Post was unnecessary. I Don't know how to delete it entirely.
 
Old 05-24-2012, 06:46 PM   #5
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Original Poster
Rep: Reputation: Disabled
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.

Last edited by amboxer21; 05-24-2012 at 07:18 PM.
 
  


Reply

Tags
bash, gtk, ubuntu, udev


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Qemu-kvm 1.0 & Spice 0.10 & Spice-Gtk 0.7.159 & Libusb 1.0.9-rc3 (official) for Ubuntu Precise LXer Syndicated Linux News 0 12-27-2011 03:50 PM
[SOLVED] Using BASH to Rename files with last mod date using stat & awk Liquid_Squelch Programming 4 12-11-2011 07:27 PM
AWK/BASH: get nth line from a file by getline feed to actions in a same awk line cristalp Programming 3 11-23-2011 12:38 PM
[SOLVED] call awk from bash script behaves differently to awk from CLI = missing newlines titanium_geek Programming 4 05-26-2011 10:06 PM
Java & JOGL & udev install on Fedora probs! striderwho Linux - Newbie 0 01-30-2005 04:44 AM


All times are GMT -5. The time now is 12:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration