8 auth_challenge(char *fmt, ...)
14 quotefmtinstall(); /* just in case */
16 p = vsmprint(fmt, arg);
21 c = mallocz(sizeof(*c), 1);
27 if((c->rpc=auth_allocrpc()) == nil
28 || auth_rpc(c->rpc, "start", p, strlen(p)) != ARok
29 || auth_rpc(c->rpc, "read", nil, 0) != ARok){
36 if(c->rpc->narg > sizeof(c->chal)-1){
37 werrstr("buffer too small for challenge");
40 memmove(c->chal, c->rpc->arg, c->rpc->narg);
41 c->nchal = c->rpc->narg;
47 auth_response(Chalstate *c)
54 werrstr("auth_response: connection not open");
58 werrstr("auth_response: nil response");
62 werrstr("auth_response: unspecified response length");
67 if(auth_rpc(c->rpc, "write", c->user, strlen(c->user)) != ARok){
69 * if this fails we're out of phase with factotum.
76 if(auth_rpc(c->rpc, "write", c->resp, c->nresp) != ARok){
78 * don't close the connection -- maybe we'll try again.
83 switch(ret = auth_rpc(c->rpc, "read", nil, 0)){
86 werrstr("factotum protocol botch %d %s", ret, c->rpc->ibuf);
89 ai = auth_getinfo(c->rpc);
100 auth_freechal(Chalstate *c)
105 auth_freerpc(c->rpc);
106 memset(c, 0xBB, sizeof(*c));