8 auth_challenge(char *fmt, ...)
14 quotefmtinstall(); /* just in case */
16 p = vsmprint(fmt, arg);
21 c = mallocz(sizeof(*c), 1);
27 if((c->afd = open("/mnt/factotum/rpc", ORDWR)) < 0){
34 if((c->rpc=auth_allocrpc(c->afd)) == nil
35 || auth_rpc(c->rpc, "start", p, strlen(p)) != ARok
36 || auth_rpc(c->rpc, "read", nil, 0) != ARok)
39 if(c->rpc->narg > sizeof(c->chal)-1){
40 werrstr("buffer too small for challenge");
43 memmove(c->chal, c->rpc->arg, c->rpc->narg);
44 c->nchal = c->rpc->narg;
50 auth_response(Chalstate *c)
57 werrstr("auth_response: connection not open");
61 werrstr("auth_response: nil response");
65 werrstr("auth_response: unspecified response length");
70 if(auth_rpc(c->rpc, "write", c->user, strlen(c->user)) != ARok){
72 * if this fails we're out of phase with factotum.
79 if(auth_rpc(c->rpc, "write", c->resp, c->nresp) != ARok){
81 * don't close the connection -- maybe we'll try again.
86 switch(ret = auth_rpc(c->rpc, "read", nil, 0)){
89 werrstr("factotum protocol botch %d %s", ret, c->rpc->ibuf);
92 ai = auth_getinfo(c->rpc);
105 auth_freechal(Chalstate *c)
113 auth_freerpc(c->rpc);
115 memset(c, 0xBB, sizeof(*c));