aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/auth/secstore/secacct.c
blob: 4390129a1bd5beab28c664d673985630f9dcbf44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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);
}