wm: infra

Download patch

ref: e720631965b13539210b843af0af013db5858a17
parent: a26704b4f61f20077fda74e24dc3bcb2a3b2c143
author: mkf <mkf@cloud9p.org>
date: Sun Aug 25 06:49:54 EDT 2024

chnvram: import (a tool to change nvram password)

--- /dev/null
+++ b/chnvram
@@ -1,0 +1,35 @@
+#!/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