Re: Keyboard-Locking

Nimrod Zimerman (zimerman@deskmail.com)
Wed, 6 Jan 1999 22:18:23 +0200


On Mon, Jan 04, 1999 at 11:49:26PM +0100, Matthias Schniedermeyer wrote:

> I'd like to have a way "lock" the keyboard. So that it isn't possible to
> write anything with the keyboard until a password or similar is entered.

You can do this in user-space, using the VT_SETMODE ioctl to the
console (you have to be in a console, not in X, to do that).

The general idea is to tell the kernel that you want to be notified when
somebody wishes to switch from this console, and just deny this operation
unless something happened (for example, the user entered a password).
(This is what X servers do. This is possibly the number one reason why X can
rather easily render a Linux machine non-accessible if a bug is encountered
that prevents the switching request from being acknowledged by it).
You have to make sure your program can't be stopped (so ignore SIGINT and
SIGTSTP), and there are possibly a few more details that I can't think of
right now.

I did this once, and it worked perfectly fine. I still have the code around
as part of my very own login program (for single-user machines, one really
doesn't need to rewrite the username and password a hundred times. I have a
system that only asks for the password once - wrote it a few weeks after I
started using Linux <g>). If you want, I can send this to you.

> Unlike Windows NT the Screen doesn't need to be blanked. I think it would
> be usefull if changing VT (ALT-F1...) remain working, but nothing more.

This isn't possible with my approach, AFAIK. Not in user space.

You can blank the screen, though.

> I think this sould be implemented as a "Magic Sysrequst" which can better
> entered "On-the-Fly" to lock the keyboard (Imagine how fast you can type
> CTRL-ALT-DEL, <ENTER> and how long you need to logout 10 times! (And then
> login 10 times!))

The least kernel stuff, the better...

This method requires you to run a program on the console when you wish to
lock it. Maybe this isn't an amazing solution, and it certainly isn't as
simple as the NT approach, but it works. And maybe you can play with the
keytables to add a key combination that would start a program - I never
tried.

Good luck.

Nimrod

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/