8 static int gotnvr; /* flag: nvr contains nvram; it could be bad */
17 * we shouldn't be writing nvram any more.
18 * the secstore/config field is now just secstore key.
26 if (readnvram(&nvr, NVread) < 0) {
27 fprint(2, "nvrcheck: can't read nvram\n");
35 csum = nvcsum(nvr.machkey, sizeof nvr.machkey);
36 if(csum != nvr.machsum) {
37 fprint(2, "\n\n ** NVR key checksum is incorrect **\n");
38 fprint(2, " ** set password to allow attaches **\n\n");
39 memset(nvr.machkey, 0, sizeof nvr.machkey);
47 nvrsetconfig(char* word)
49 /* config block is on device `word' */
58 char nkey1[DESKEYLEN];
59 static char zeroes[DESKEYLEN];
61 if(memcmp(nvr.machkey, zeroes, DESKEYLEN) == 0) {
62 print("no password set\n");
67 print("%s password:", service);
68 /* could turn off echo here */
70 if ((ln = Brdline(&bin, '\n')) == nil)
72 ln[Blinelen(&bin)-1] = '\0';
74 /* could turn on echo here */
75 memset(nkey1, 0, DESKEYLEN);
77 if(memcmp(nkey1, nvr.machkey, DESKEYLEN) == 0) {
82 print("Bad password\n");
88 static char *keyspec = "proto=p9any role=server";
96 if(access("/mnt/factotum", 0) < 0)
97 if((fd = open("/srv/factotum", ORDWR)) >= 0)
98 mount(fd, -1, "/mnt", MBEFORE, "");
99 if((fd = open("/mnt/factotum/rpc", ORDWR)) < 0)
101 if((rpc = auth_allocrpc(fd)) == nil){
105 if(auth_rpc(rpc, "start", keyspec, strlen(keyspec)) != ARok){
122 authread(Chan *chan, File *file, uchar *data, int count)
127 if((rpc = file->auth) == nil){
128 snprint(chan->err, sizeof(chan->err),
133 switch(auth_rpc(rpc, "read", nil, 0)){
135 snprint(chan->err, sizeof(chan->err),
136 "authread: auth protocol not finished");
139 if((ai = auth_getinfo(rpc)) == nil)
141 file->uid = strtouid(ai->cuid);
144 snprint(chan->err, sizeof(chan->err),
145 "unknown user '%s'", ai->cuid);
150 if(count < rpc->narg){
151 snprint(chan->err, sizeof(chan->err),
152 "not enough data in auth read");
155 memmove(data, rpc->arg, rpc->narg);
159 rerrstr(chan->err, sizeof(chan->err));
165 authwrite(Chan *chan, File *file, uchar *data, int count)
169 if((rpc = file->auth) == nil){
170 snprint(chan->err, sizeof(chan->err),
174 if(auth_rpc(rpc, "write", data, count) != ARok){
175 rerrstr(chan->err, sizeof(chan->err));