| plan 9 kernel history: overview | file list | diff list |
1993/0501/port/auth.c (diff list | history)
| 1993/0428/sys/src/9/port/auth.c:15,25 – 1993/0501/sys/src/9/port/auth.c:15,23 (short | long | prev | next) | ||
| 1993/0330 | char tbuf[TICKETLEN]; /* remote ticket */ }; | |
| 1993/0408 |
| |
| 1993/0330 | Crypt *cache; /* cache of tickets */ char cchal[CHALLEN]; /* client challenge */ char schal[CHALLEN]; /* server challenge */ | |
| 1993/0428/sys/src/9/port/auth.c:26,32 – 1993/0501/sys/src/9/port/auth.c:24,29 | ||
| 1993/0330 | char authid[NAMELEN]; /* server encryption uid */ char authdom[DOMLEN]; /* server encryption domain */ ulong cid; /* challenge id */ | |
| 1993/0408 |
| |
| 1993/0330 | }; struct | |
| 1993/0428/sys/src/9/port/auth.c:45,51 – 1993/0501/sys/src/9/port/auth.c:42,48 | ||
| 1993/0330 | int iseve(void) { | |
| 1993/0501 | return strcmp(eve, up->user) == 0; | |
| 1993/0330 | } /* | |
| 1993/0428/sys/src/9/port/auth.c:111,134 – 1993/0501/sys/src/9/port/auth.c:108,128 | ||
| 1993/0330 | nexterror(); } | |
| 1993/0407 | ||
| 1993/0408 |
| |
| 1993/0501 | /* * if two processes get here at the same * time with no session exchanged, we have * a race. */ | |
| 1993/0330 | s = c->session; if(s == 0){ | |
| 1993/0501 | /* * no session exchanged yet */ | |
| 1993/0330 | s = malloc(sizeof(Session)); | |
| 1993/0408 |
| |
| 1993/0501 | if(s == 0) | |
| 1993/0330 | error(Enomem); | |
| 1993/0408 |
| |
| 1993/0501 | memset(s, 0, sizeof(Session)); | |
| 1993/0407 | ||
| 1993/0408 |
| |
| 1993/0407 | /* * Exchange a session message with the server. * If an error occurs reading or writing, | |
| 1993/0428/sys/src/9/port/auth.c:144,155 – 1993/0501/sys/src/9/port/auth.c:138,150 | ||
| 1993/0407 | n = convS2M(&f, buf); if((*devtab[c->type].write)(c, buf, n, 0) != n) error(Emountrpc); | |
| 1993/0501 | dkhack: | |
| 1993/0407 | n = (*devtab[c->type].read)(c, buf, sizeof buf, 0); if(n == 2 && buf[0] == 'O' && buf[1] == 'K') | |
| 1993/0501 | goto dkhack; | |
| 1993/0407 | poperror(); if(convM2S(buf, &f, n) == 0){ | |
| 1993/0411 |
| |
| 1993/0501 | free(s); | |
| 1993/0407 | error(Emountrpc); } switch(f.type){ | |
| 1993/0428/sys/src/9/port/auth.c:159,174 – 1993/0501/sys/src/9/port/auth.c:154,168 | ||
| 1993/0407 | memmove(s->authdom, f.authdom, DOMLEN); break; case Rerror: | |
| 1993/0411 |
| |
| 1993/0501 | free(s); | |
| 1993/0407 | error(f.ename); default: | |
| 1993/0411 |
| |
| 1993/0501 | free(s); | |
| 1993/0407 | error(Emountrpc); } | |
| 1993/0330 | } | |
| 1993/0408 |
| |
| 1993/0501 | c->session = s; | |
| 1993/0330 | } | |
| 1993/0408 |
| |
| 1993/0330 | /* * If server requires no ticket, or user is "none", or a ticket | |
| 1993/0428/sys/src/9/port/auth.c:175,197 – 1993/0501/sys/src/9/port/auth.c:169,187 | ||
| 1993/0330 | * is already cached, zero the request type */ tr.type = AuthTreq; | |
| 1993/0408 |
| |
| 1993/0501 | if(strcmp(up->user, "none") == 0 || c->session->authid[0] == 0) | |
| 1993/0330 | tr.type = 0; | |
| 1993/0408 |
| |
| 1993/0501 | else for(cp = s->cache; cp; cp = cp->next) if(strcmp(cp->t.cuid, up->user) == 0){ tr.type = 0; break; } | |
| 1993/0330 | /* create ticket request */ | |
| 1993/0408 |
| |
| 1993/0330 |
| |
| 1993/0501 | memmove(tr.chal, c->session->schal, CHALLEN); memmove(tr.authid, c->session->authid, NAMELEN); memmove(tr.authdom, c->session->authdom, DOMLEN); memmove(tr.uid, up->user, NAMELEN); | |
| 1993/0330 | memmove(tr.hostid, eve, NAMELEN); convTR2M(&tr, (char*)arg[1]); | |
| 1993/0428/sys/src/9/port/auth.c:229,235 – 1993/0501/sys/src/9/port/auth.c:219,225 | ||
| 1993/0330 | convM2T(tbuf, &cp->t, evekey); if(cp->t.num != AuthTc) error("bad AuthTc in ticket"); | |
| 1993/0501 | if(strncmp(up->user, cp->t.cuid, NAMELEN) != 0) | |
| 1993/0330 | error("bad uid in ticket"); if(memcmp(cp->t.chal, s->schal, CHALLEN) != 0) error("bad chal in ticket"); | |
| 1993/0428/sys/src/9/port/auth.c:239,245 – 1993/0501/sys/src/9/port/auth.c:229,235 | ||
| 1993/0330 | lock(s); l = &s->cache; for(ncp = s->cache; ncp; ncp = *l){ | |
| 1993/0501 | if(strcmp(ncp->t.cuid, up->user) == 0){ | |
| 1993/0330 | *l = ncp->next; freecrypt(ncp); break; | |
| 1993/0428/sys/src/9/port/auth.c:278,284 – 1993/0501/sys/src/9/port/auth.c:268,274 | ||
| 1993/0330 | ulong id, dofree; /* no authentication if user is "none" or if no ticket required by remote */ | |
| 1993/0501 | if(s == 0 || s->authid[0] == 0 || strcmp(up->user, "none") == 0){ | |
| 1993/0330 | memset(f->ticket, 0, TICKETLEN); memset(f->auth, 0, AUTHENTLEN); return 0; | |
| 1993/0428/sys/src/9/port/auth.c:288,294 – 1993/0501/sys/src/9/port/auth.c:278,284 | ||
| 1993/0330 | dofree = 0; | |
| 1993/0403 | lock(s); | |
| 1993/0330 | for(cp = s->cache; cp; cp = cp->next) | |
| 1993/0501 | if(strcmp(cp->t.cuid, up->user) == 0) | |
| 1993/0330 | break; | |
| 1993/0403 | id = s->cid++; | |
| 1993/0428/sys/src/9/port/auth.c:302,309 – 1993/0501/sys/src/9/port/auth.c:292,299 | ||
| 1993/0330 | cp = newcrypt(); cp->t.num = AuthTs; memmove(cp->t.chal, s->schal, CHALLEN); | |
| 1993/0501 | memmove(cp->t.cuid, up->user, NAMELEN); memmove(cp->t.suid, up->user, NAMELEN); | |
| 1993/0330 | memmove(cp->t.key, evekey, DESKEYLEN); convT2M(&cp->t, f->ticket, evekey); dofree = 1; | |
| 1993/0428/sys/src/9/port/auth.c:333,344 – 1993/0501/sys/src/9/port/auth.c:323,334 | ||
| 1993/0330 | ||
| 1993/0403 | lock(s); | |
| 1993/0330 | for(cp = s->cache; cp; cp = cp->next) | |
| 1993/0501 | if(strcmp(cp->t.cuid, up->user) == 0) | |
| 1993/0330 | break; | |
| 1993/0403 | unlock(s); | |
| 1993/0330 | /* we're getting around authentication */ | |
| 1993/0501 | if(s == 0 || cp == 0 || s->authid[0] == 0 || strcmp(up->user, "none") == 0) | |
| 1993/0330 | return; convM2A(f->rauth, &cp->a, cp->t.key); | |
| 1993/0428/sys/src/9/port/auth.c:361,368 – 1993/0501/sys/src/9/port/auth.c:351,358 | ||
| 1993/0330 | * * The protocol is * 1) read ticket request from #c/authenticate | |
| 1993/0428 |
| |
| 1993/0501 | * 2) write ticket to #c/authenticate. if it matchs the challenge the * user is changed to the suid field of the ticket | |
| 1993/0330 | * 3) read authenticator (to confirm this is the server advertised) */ long | |
| 1993/0428/sys/src/9/port/auth.c:380,392 – 1993/0501/sys/src/9/port/auth.c:370,381 | ||
| 1993/0330 | error(Ebadarg); c->aux = newcrypt(); cp = c->aux; | |
| 1993/0428 | ||
| 1993/0330 | memset(&tr, 0, sizeof(tr)); tr.type = AuthTreq; strcpy(tr.hostid, eve); strcpy(tr.authid, eve); strcpy(tr.authdom, hostdomain); | |
| 1993/0501 | strcpy(tr.uid, up->user); | |
| 1993/0330 | for(i = 0; i < CHALLEN; i++) tr.chal[i] = nrand(256); memmove(cp->a.chal, tr.chal, CHALLEN); | |
| 1993/0428/sys/src/9/port/auth.c:398,410 – 1993/0501/sys/src/9/port/auth.c:387,396 | ||
| 1993/0330 | if(n != AUTHENTLEN) error(Ebadarg); cp = c->aux; | |
| 1993/0428 | ||
| 1993/0330 | cp->a.num = AuthAs; memmove(cp->a.chal, cp->t.chal, CHALLEN); cp->a.id = 0; | |
| 1993/0428 |
| |
| 1993/0501 | convA2M(&cp->a, a, cp->t.key); | |
| 1993/0330 | freecrypt(cp); c->aux = 0; } | |
| 1993/0428/sys/src/9/port/auth.c:416,438 – 1993/0501/sys/src/9/port/auth.c:402,416 | ||
| 1993/0330 | { Crypt *cp; | |
| 1993/0428 |
| |
| 1993/0501 | if(n != TICKETLEN) | |
| 1993/0330 | error(Ebadarg); if(c->aux == 0) error(Ebadarg); cp = c->aux; | |
| 1993/0428 |
| |
| 1993/0501 | convM2T(a, &cp->t, evekey); | |
| 1993/0330 | if(cp->t.num != AuthTs || memcmp(cp->a.chal, cp->t.chal, CHALLEN)) error(Eperm); | |
| 1993/0428 |
| |
| 1993/0330 |
| |
| 1993/0501 | memmove(up->user, cp->t.suid, NAMELEN); | |
| 1993/0330 | return n; } | |
| 1993/0428/sys/src/9/port/auth.c:451,517 – 1993/0501/sys/src/9/port/auth.c:429,445 | ||
| 1993/0330 | if(c->aux == 0) c->aux = newcrypt(); cp = c->aux; | |
| 1993/0428 |
| |
| 1993/0501 | convM2T(a, &cp->t, evekey); | |
| 1993/0402 | if(cp->t.num != AuthTc) | |
| 1993/0330 | error(Ebadarg); | |
| 1993/0402 |
| |
| 1993/0501 | if(strcmp(up->user, cp->t.cuid)) | |
| 1993/0402 | error(cp->t.cuid); | |
| 1993/0428 |
| |
| 1993/0501 | convM2A(a+TICKETLEN, &cp->a, cp->t.key); | |
| 1993/0330 | if(cp->a.num != AuthAs || memcmp(cp->t.chal, cp->a.chal, CHALLEN)) error(Eperm); | |
| 1993/0428 |
| |
| 1993/0330 |
| |
| 1993/0428/sys/src/9/port/auth.c:557,564 – 1993/0501/sys/src/9/port/auth.c:485,492 | ||
| 1993/0330 | error(Ebadarg); if(strcmp(a, "none") != 0) error(Eperm); | |
| 1993/0501 | memset(up->user, 0, NAMELEN); strcpy(up->user, "none"); | |
| 1993/0330 | return n; } | |
| 1993/0428/sys/src/9/port/auth.c:581,587 – 1993/0501/sys/src/9/port/auth.c:509,515 | ||
| 1993/0330 | if(buf[0] == 0) error(Ebadarg); memmove(eve, buf, NAMELEN); | |
| 1993/0501 | memmove(up->user, buf, NAMELEN); | |
| 1993/0330 | return n; } | |