From owner-freebsd-hackers Sat Sep 26 02:03:42 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id CAA09895 for freebsd-hackers-outgoing; Sat, 26 Sep 1998 02:03:42 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from outmail.utsunomiya-u.ac.jp (outmail.utsunomiya-u.ac.jp [160.12.196.3]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id CAA09867 for ; Sat, 26 Sep 1998 02:03:31 -0700 (PDT) (envelope-from yokota@zodiac.mech.utsunomiya-u.ac.jp) Received: from zodiac.mech.utsunomiya-u.ac.jp (IDENT:sN7C6F5xQS/yECDQsN5LB2mvtjWyceAA@zodiac.mech.utsunomiya-u.ac.jp [160.12.42.1]) by outmail.utsunomiya-u.ac.jp (8.9.1/8.9.1) with ESMTP id SAA01488; Sat, 26 Sep 1998 18:02:45 +0900 (JST) Received: from zodiac.mech.utsunomiya-u.ac.jp (zodiac.mech.utsunomiya-u.ac.jp [160.12.42.1]) by zodiac.mech.utsunomiya-u.ac.jp (8.7.6+2.6Wbeta7/3.4W/zodiac-May96) with ESMTP id SAA19912; Sat, 26 Sep 1998 18:03:49 +0900 (JST) Message-Id: <199809260903.SAA19912@zodiac.mech.utsunomiya-u.ac.jp> To: Martin Cracauer cc: "Brian W. Buchanan" , Mike Smith , hackers@FreeBSD.ORG, yokota@zodiac.mech.utsunomiya-u.ac.jp Subject: Re: vty lock In-reply-to: Your message of "Wed, 23 Sep 1998 12:42:32 +0200." <19980923124232.A20756@cons.org> References: <199809220806.BAA00624@word.smith.net.au> <19980923124232.A20756@cons.org> Date: Sat, 26 Sep 1998 18:03:49 +0900 From: Kazutaka YOKOTA Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >> I have to terminate or shell out of whatever I'm running at the moment on >> each vty and run it, then enter my password 9 or 10 times when I return to >> the console. >> >> Linux's vlock lets you specify -a to instantly lock ALL vtys, which is the >> functionality I'm mainly looking for. > >Then why don't you add that option to our lock? Simplest solution >would be to prevent the console driver from switching consoles, which >could be done with a simple ioctl for syscons and pcvt. > >Martin Linux has the ioctls VT_LOCKSWITCH and VT_UNLOCKSWITCH, which our syscons and pcvt don't have. However, if all you want to do is to prevent the user from switching away from the current vty, you can make `lock' use the ioctl VT_SEMODE to set the switching mode to VT_PROCESS and refuse vty switching until the user types the correct password (or until timeout expires). This technique should work with both syscons and pcvt. #include ... int fd; void relase(int arg) { /* always refuse to release our vty */ ioctl(fd, VT_RELDISP, VT_FALSE); } void acquire(int arg) { ioctl(fd, VT_RELDISP, VT_ACKACQ); } main() { struct vt_mode mode; fd = fileno(stdin); signal(SIGUSR1, release) signal(SIGUSR2, acquire); mode.mode = VT_PROCESSS; mode.relsig = SIGUSR1; mode.acqsig = SIGUSR2; mode.frsig = SIGUSR1; /* not used */ ioctl(fd, VT_SETMODE, &mode); ... /* clean up before quiting */ mode.mode = VT_AUTO; ioctl(fd, VT_SETMODE, &mode); } Kazu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message