12 nvrsetconfig(char* word)
14 /* config block is on device `word' */
19 static char *keyspec = "proto=p9any role=server";
27 if(access("/mnt/factotum", 0) < 0)
28 if((fd = open("/srv/factotum", ORDWR)) >= 0)
29 mount(fd, -1, "/mnt", MBEFORE, "");
30 if((fd = open("/mnt/factotum/rpc", ORDWR)) < 0)
32 if((rpc = auth_allocrpc(fd)) == nil){
36 if(auth_rpc(rpc, "start", keyspec, strlen(keyspec)) != ARok){
55 authread(File *file, uchar *data, int count)
62 if((rpc = file->auth) == nil){
63 snprint(chan->err, sizeof(chan->err),
68 switch(auth_rpc(rpc, "read", nil, 0)){
70 snprint(chan->err, sizeof(chan->err),
71 "authread: auth protocol not finished");
74 if((ai = auth_getinfo(rpc)) == nil)
76 file->uid = strtouid(ai->cuid);
78 snprint(chan->err, sizeof(chan->err),
79 "unknown user '%s'", ai->cuid);
86 if(count < rpc->narg){
87 snprint(chan->err, sizeof(chan->err),
88 "not enough data in auth read");
91 memmove(data, rpc->arg, rpc->narg);
95 rerrstr(chan->err, sizeof(chan->err));
101 authwrite(File *file, uchar *data, int count)
107 if((rpc = file->auth) == nil){
108 snprint(chan->err, sizeof(chan->err),
112 if(auth_rpc(rpc, "write", data, count) != ARok){
113 rerrstr(chan->err, sizeof(chan->err));