| plan 9 kernel history: overview | file list | diff list |
1993/0408/port/auth.c (diff list | history)
| 1993/0407/sys/src/9/port/auth.c:19,24 – 1993/0408/sys/src/9/port/auth.c:19,25 (short | long | prev | next) | ||
| 1993/0330 | struct Session { Lock; | |
| 1993/0408 | Lock send; | |
| 1993/0330 | Crypt *cache; /* cache of tickets */ char cchal[CHALLEN]; /* client challenge */ char schal[CHALLEN]; /* server challenge */ | |
| 1993/0407/sys/src/9/port/auth.c:25,30 – 1993/0408/sys/src/9/port/auth.c:26,32 | ||
| 1993/0330 | char authid[NAMELEN]; /* server encryption uid */ char authdom[DOMLEN]; /* server encryption domain */ ulong cid; /* challenge id */ | |
| 1993/0408 | int valid; | |
| 1993/0330 | }; struct | |
| 1993/0407/sys/src/9/port/auth.c:109,129 – 1993/0408/sys/src/9/port/auth.c:111,134 | ||
| 1993/0330 | nexterror(); } | |
| 1993/0407 |
| |
| 1993/0408 | /* add a session structure to the channel if it has none */ lock(c); | |
| 1993/0330 | s = c->session; if(s == 0){ | |
| 1993/0407 |
| |
| 1993/0330 | s = malloc(sizeof(Session)); | |
| 1993/0408 | if(s == 0){ unlock(c); | |
| 1993/0330 | error(Enomem); | |
| 1993/0408 | } c->session = s; } unlock(c); | |
| 1993/0407 | ||
| 1993/0408 | /* back off if someone else is doing an fsession */ while(!canlock(&s->send)) sched(); if(s->valid == 0){ | |
| 1993/0407 | /* * Exchange a session message with the server. * If an error occurs reading or writing, | |
| 1993/0407/sys/src/9/port/auth.c:144,150 – 1993/0408/sys/src/9/port/auth.c:149,155 | ||
| 1993/0407 | n = (*devtab[c->type].read)(c, buf, sizeof buf, 0); poperror(); if(convM2S(buf, &f, n) == 0){ | |
| 1993/0408 | unlock(s); | |
| 1993/0407 | error(Emountrpc); } switch(f.type){ | |
| 1993/0407/sys/src/9/port/auth.c:154,168 – 1993/0408/sys/src/9/port/auth.c:159,174 | ||
| 1993/0407 | memmove(s->authdom, f.authdom, DOMLEN); break; case Rerror: | |
| 1993/0408 | unlock(s); | |
| 1993/0407 | error(f.ename); default: | |
| 1993/0408 | unlock(s); | |
| 1993/0407 | error(Emountrpc); } | |
| 1993/0330 | } | |
| 1993/0408 | s->valid = 1; | |
| 1993/0330 | } | |
| 1993/0408 | unlock(&s->send); | |
| 1993/0330 | /* * If server requires no ticket, or user is "none", or a ticket | |
| 1993/0407/sys/src/9/port/auth.c:169,186 – 1993/0408/sys/src/9/port/auth.c:175,196 | ||
| 1993/0330 | * is already cached, zero the request type */ tr.type = AuthTreq; | |
| 1993/0408 | if(strcmp(u->p->user, "none") == 0 || s->authid[0] == 0) | |
| 1993/0330 | tr.type = 0; | |
| 1993/0408 | else{ lock(s); for(cp = s->cache; cp; cp = cp->next) if(strcmp(cp->t.cuid, u->p->user) == 0){ tr.type = 0; break; } unlock(s); } | |
| 1993/0330 | /* create ticket request */ | |
| 1993/0408 | memmove(tr.chal, s->schal, CHALLEN); memmove(tr.authid, s->authid, NAMELEN); memmove(tr.authdom, s->authdom, DOMLEN); | |
| 1993/0330 | memmove(tr.uid, u->p->user, NAMELEN); memmove(tr.hostid, eve, NAMELEN); convTR2M(&tr, (char*)arg[1]); | |