wm: infra

ref: b2571022c75be091e743a58c487105af200de28b
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