#!/bin/rc
# Lock console, only useful if rio is not running (i.e. servers)
rfork en
pwd=$home/lib/conslock.hash
fn getpass {
{
echo -n 'passwd: ' > /dev/cons
echo rawon >[1=4]
{ echo $sysname ; read ; echo $sysname } | md5sum
echo rawoff >[1=4]
echo > /dev/cons
}>[4] /dev/consctl
}
if(! test -e $pwd){
echo 'console security not configured'
getpass > $pwd
}
echo console locked
while(;){
if(getpass | cmp -s /fd/0 $pwd)
exit ''
sleep 1
}
|