Plan 9 from Bell Labs’s /usr/web/sources/contrib/someone/root/rc/bin/editfactotumkeys

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


#!/bin/rc

rfork n
ramfs
cd /tmp

switch($#*){
case 0
	editor=acme
case 1
	editor=$1
case *
	echo 'usage: editfactotumkeys [editor]' >[1=2]
	exit usage
}

myfactotum=1
if(! syscall open /mnt/factotum/ctl 2 >[2]/dev/null)
	myfactotum=0

echo fetching keys...
if(! auth/secstore -g factotum)
	exit secstore
cp factotum factotum.o || exit secstore
$editor factotum
if(! cmp factotum factotum.o >[2]/dev/null >/dev/null){
	sleep 2	# wait for samterm to exit
	echo 'keys modified; writing back...'
	auth/secstore -p factotum
	# why not use read -m here?  no one else uses aux/lines.
	if(~ $myfactotum 1)
		aux/lines <factotum >/mnt/factotum/ctl
}
if not
	echo 'keys unchanged.'

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.