7 auth_challenge(char *fmt, ...)
13 quotefmtinstall(); /* just in case */
15 p = vsmprint(fmt, arg);
20 c = mallocz(sizeof(*c), 1);
26 if((c->afd = open("/mnt/factotum/rpc", ORDWR)) < 0){
33 if((c->rpc=auth_allocrpc(c->afd)) == nil
34 || auth_rpc(c->rpc, "start", p, strlen(p)) != ARok
35 || auth_rpc(c->rpc, "read", nil, 0) != ARok)
38 if(c->rpc->narg > sizeof(c->chal)-1){
39 werrstr("buffer too small for challenge");
42 memmove(c->chal, c->rpc->arg, c->rpc->narg);
43 c->nchal = c->rpc->narg;
49 auth_response(Chalstate *c)
56 werrstr("auth_response: connection not open");
60 werrstr("auth_response: nil response");
64 werrstr("auth_response: unspecified response length");
69 if(auth_rpc(c->rpc, "write", c->user, strlen(c->user)) != ARok){
71 * if this fails we're out of phase with factotum.
78 if(auth_rpc(c->rpc, "write", c->dom, strlen(c->dom)) != ARok){
80 * if this fails we're out of phase with factotum.
87 if(auth_rpc(c->rpc, "write", c->resp, c->nresp) != ARok){
89 * don't close the connection -- maybe we'll try again.
94 switch(ret = auth_rpc(c->rpc, "read", nil, 0)){
97 werrstr("factotum protocol botch %d %s", ret, c->rpc->ibuf);
100 ai = auth_getinfo(c->rpc);
106 auth_freerpc(c->rpc);
113 auth_freechal(Chalstate *c)
121 auth_freerpc(c->rpc);
123 memset(c, 0xBB, sizeof(*c));