wm: infra

ref: e720631965b13539210b843af0af013db5858a17
dir: /chnvram/

View raw version
#!/bin/rc

# in Plan 9 passwords are encrypted via the key in nvram
# if you change nvram key, your users cant login with passwords.
# which is -- very bad.

# but sometimes you've got to change nvram password,
# here is a tool that preserves your users passwords;
# while also changing your nvram.

if(! ~ $1 -y){
	echo 'this is a dangrous program;
if you don''t know how to use it, maybe you should avoid using it.' >[1=2]
	exit usage
}

auth/keyfs
mkdir -p /tmp/keys

echo copying keys...
for(i in /mnt/keys){
	user=`{basename $i}
	for(i in /mnt/keys/*){
		cat $i/secret > /tmp/keys/$user
	}
}

echo running auth/wrkey...
auth/wrkey

for(i in /tmp/keys/*){
	user=`{basename $i}
	wm/chusr -p `{cat $i} $user
}
echo done