aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/secstore/secacct.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-02-11 19:39:51 +0000
committerrsc <devnull@localhost>2005-02-11 19:39:51 +0000
commit096ff3e14a188992d2dfe59c7fd3f5d6da791331 (patch)
tree7d570f58a3e398c7f04c04a34bd330aaf077ee45 /src/cmd/secstore/secacct.c
parentd93fca6a7ab52f518d3e8aca1fc94139313b97ad (diff)
downloadplan9port-096ff3e14a188992d2dfe59c7fd3f5d6da791331.tar.gz
plan9port-096ff3e14a188992d2dfe59c7fd3f5d6da791331.tar.bz2
plan9port-096ff3e14a188992d2dfe59c7fd3f5d6da791331.zip
add secstored; use readcons
Diffstat (limited to 'src/cmd/secstore/secacct.c')
-rw-r--r--src/cmd/secstore/secacct.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/cmd/secstore/secacct.c b/src/cmd/secstore/secacct.c
new file mode 100644
index 00000000..4390129a
--- /dev/null
+++ b/src/cmd/secstore/secacct.c
@@ -0,0 +1,35 @@
+#include <u.h>
+#include <libc.h>
+#include <ip.h>
+
+int verbose = 1;
+static char testmess[] = "__secstore\tPAK\nC=%s\nm=0\n";
+
+void
+main(int argc, char **argv)
+{
+ int n, m, fd;
+ uchar buf[500];
+
+ if(argc != 2)
+ exits("usage: secacct userid");
+
+ n = snprint((char*)buf, sizeof buf, testmess, argv[1]);
+ hnputs(buf, 0x8000+n-2);
+
+ fd = dial("tcp!ruble.cs.bell-labs.com!5356", 0, 0, 0);
+ if(fd < 0)
+ exits("cannot dial ruble");
+ if(write(fd, buf, n) != n || readn(fd, buf, 2) != 2)
+ exits("cannot exchange first round");
+ n = ((buf[0]&0x7f)<<8) + buf[1];
+ if(n+1 > sizeof buf)
+ exits("implausibly large count");
+ m = readn(fd, buf, n);
+ close(fd);
+ if(m != n)
+ fprint(2,"short read from secstore\n");
+ buf[m] = 0;
+ print("%s\n", (char*)buf);
+ exits(0);
+}