aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/netkey.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-02-11 19:51:21 +0000
committerrsc <devnull@localhost>2005-02-11 19:51:21 +0000
commit7d59ed711467b2b2c8ac25f86724225c8be7524c (patch)
treea8d6ebdfda94c8e4ff2a2d8f8f0dfa10f8fe1709 /src/cmd/netkey.c
parentcf7bdb33d49aef8a4add73ee15f631f3fc0203d6 (diff)
downloadplan9port-7d59ed711467b2b2c8ac25f86724225c8be7524c.tar.gz
plan9port-7d59ed711467b2b2c8ac25f86724225c8be7524c.tar.bz2
plan9port-7d59ed711467b2b2c8ac25f86724225c8be7524c.zip
changes
Diffstat (limited to 'src/cmd/netkey.c')
-rw-r--r--src/cmd/netkey.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/cmd/netkey.c b/src/cmd/netkey.c
new file mode 100644
index 00000000..7e988023
--- /dev/null
+++ b/src/cmd/netkey.c
@@ -0,0 +1,47 @@
+#include <u.h>
+#include <libc.h>
+#include <libsec.h>
+#include <authsrv.h>
+
+void
+usage(void)
+{
+ fprint(2, "usage: netkey\n");
+ exits("usage");
+}
+
+void
+main(int argc, char *argv[])
+{
+ char *chal, *pass, buf[32], key[DESKEYLEN];
+ char *s;
+ int n;
+
+ ARGBEGIN{
+ default:
+ usage();
+ }ARGEND
+ if(argc)
+ usage();
+
+ s = getenv("service");
+ if(s && strcmp(s, "cpu") == 0){
+ fprint(2, "netkey must not be run on the cpu server\n");
+ exits("boofhead");
+ }
+
+ pass = readcons("password", nil, 1);
+ if(pass == nil)
+ sysfatal("reading password: %r");
+ passtokey(key, pass);
+
+ for(;;){
+ chal = readcons("challenge", nil, 0);
+ if(chal == nil || *chal == 0)
+ exits(nil);
+ n = strtol(chal, 0, 10);
+ sprint(buf, "%d", n);
+ netcrypt(key, buf);
+ print("response: %s\n", buf);
+ }
+}