Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/rc/conslock

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/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
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.