Lines Matching refs:chap

256 chap_StartChild(struct chap *chap, char *prog, const char *name)  in chap_StartChild()  argument
263 if (chap->child.fd != -1) { in chap_StartChild()
281 switch ((chap->child.pid = fork())) { in chap_StartChild()
288 chap->child.pid = 0; in chap_StartChild()
320 chap->auth.physical->dl->bundle, 0, pid); in chap_StartChild()
328 chap->child.fd = out[0]; in chap_StartChild()
329 chap->child.buf.len = 0; in chap_StartChild()
330 write(in[1], chap->auth.in.name, strlen(chap->auth.in.name)); in chap_StartChild()
332 write(in[1], chap->challenge.peer + 1, *chap->challenge.peer); in chap_StartChild()
342 chap_Cleanup(struct chap *chap, int sig) in chap_Cleanup() argument
344 if (chap->child.pid) { in chap_Cleanup()
347 close(chap->child.fd); in chap_Cleanup()
348 chap->child.fd = -1; in chap_Cleanup()
350 kill(chap->child.pid, SIGTERM); in chap_Cleanup()
351 chap->child.pid = 0; in chap_Cleanup()
352 chap->child.buf.len = 0; in chap_Cleanup()
361 *chap->challenge.local = *chap->challenge.peer = '\0'; in chap_Cleanup()
363 chap->peertries = 0; in chap_Cleanup()
368 chap_Respond(struct chap *chap, char *name, char *key in chap_Respond() argument
376 ans = chap_BuildAnswer(name, key, chap->auth.id, chap->challenge.peer in chap_Respond()
378 , type, chap->challenge.local, chap->authresponse, lm in chap_Respond()
383 ChapOutput(chap->auth.physical, CHAP_RESPONSE, chap->auth.id, in chap_Respond()
386 chap->NTRespSent = !lm; in chap_Respond()
391 ChapOutput(chap->auth.physical, CHAP_FAILURE, chap->auth.id, in chap_Respond()
399 struct chap *chap = descriptor2chap(d); in chap_UpdateSet() local
401 if (r && chap && chap->child.fd != -1) { in chap_UpdateSet()
402 FD_SET(chap->child.fd, r); in chap_UpdateSet()
403 if (*n < chap->child.fd + 1) in chap_UpdateSet()
404 *n = chap->child.fd + 1; in chap_UpdateSet()
405 log_Printf(LogTIMER, "Chap: fdset(r) %d\n", chap->child.fd); in chap_UpdateSet()
415 struct chap *chap = descriptor2chap(d); in chap_IsSet() local
417 return chap && chap->child.fd != -1 && FD_ISSET(chap->child.fd, fdset); in chap_IsSet()
424 struct chap *chap = descriptor2chap(d); in chap_Read() local
427 got = read(chap->child.fd, chap->child.buf.ptr + chap->child.buf.len, in chap_Read()
428 sizeof chap->child.buf.ptr - chap->child.buf.len - 1); in chap_Read()
431 chap_Cleanup(chap, SIGTERM); in chap_Read()
434 chap_Cleanup(chap, SIGTERM); in chap_Read()
438 chap->child.buf.len += got; in chap_Read()
439 chap->child.buf.ptr[chap->child.buf.len] = '\0'; in chap_Read()
440 name = chap->child.buf.ptr; in chap_Read()
448 if (chap->child.buf.len == sizeof chap->child.buf.ptr - 1) { in chap_Read()
450 chap_Cleanup(chap, SIGTERM); in chap_Read()
454 int lanman = chap->auth.physical->link.lcp.his_authtype == 0x80 && in chap_Read()
455 ((chap->NTRespSent && in chap_Read()
456 IsAccepted(chap->auth.physical->link.lcp.cfg.chap80lm)) || in chap_Read()
457 !IsAccepted(chap->auth.physical->link.lcp.cfg.chap80nt)); in chap_Read()
467 chap_Respond(chap, name, key in chap_Read()
469 , chap->auth.physical->link.lcp.his_authtype, lanman in chap_Read()
472 chap_Cleanup(chap, 0); in chap_Read()
489 struct chap *chap = auth2chap(authp); in chap_ChallengeInit() local
495 if (!*chap->challenge.local) { in chap_ChallengeInit()
497 cp = chap->challenge.local; in chap_ChallengeInit()
516 for (i = 0; i < *chap->challenge.local; i++) in chap_ChallengeInit()
526 struct chap *chap = auth2chap(authp); in chap_Challenge() local
535 if (!*chap->challenge.local) in chap_Challenge()
541 chap->challenge.local, 1 + *chap->challenge.local, NULL); in chap_Challenge()
545 chap->challenge.local, 1 + *chap->challenge.local + len, NULL); in chap_Challenge()
655 chap_HaveAnotherGo(struct chap *chap) in chap_HaveAnotherGo() argument
657 if (++chap->peertries < 3) { in chap_HaveAnotherGo()
659 *chap->challenge.local = '\0'; in chap_HaveAnotherGo()
660 chap_Challenge(&chap->auth); in chap_HaveAnotherGo()
669 chap_Init(struct chap *chap, struct physical *p) in chap_Init() argument
671 chap->desc.type = CHAP_DESCRIPTOR; in chap_Init()
672 chap->desc.UpdateSet = chap_UpdateSet; in chap_Init()
673 chap->desc.IsSet = chap_IsSet; in chap_Init()
674 chap->desc.Read = chap_Read; in chap_Init()
675 chap->desc.Write = chap_Write; in chap_Init()
676 chap->child.pid = 0; in chap_Init()
677 chap->child.fd = -1; in chap_Init()
678 auth_Init(&chap->auth, p, chap_Challenge, chap_Success, chap_Failure); in chap_Init()
679 *chap->challenge.local = *chap->challenge.peer = '\0'; in chap_Init()
681 chap->NTRespSent = 0; in chap_Init()
682 chap->peertries = 0; in chap_Init()
687 chap_ReInit(struct chap *chap) in chap_ReInit() argument
689 chap_Cleanup(chap, SIGTERM); in chap_ReInit()
696 struct chap *chap = &p->dl->chap; in chap_Input() local
719 if ((bp = auth_ReadHeader(&chap->auth, bp)) == NULL && in chap_Input()
720 ntohs(chap->auth.in.hdr.length) == 0) in chap_Input()
722 else if (chap->auth.in.hdr.code == 0 || chap->auth.in.hdr.code > MAXCHAPCODE) in chap_Input()
724 chap->auth.in.hdr.code); in chap_Input()
729 if (chap->auth.in.hdr.code != CHAP_CHALLENGE && in chap_Input()
730 chap->auth.id != chap->auth.in.hdr.id && in chap_Input()
734 chapcodes[chap->auth.in.hdr.code], chap->auth.in.hdr.id, in chap_Input()
735 chap->auth.id); in chap_Input()
739 chap->auth.id = chap->auth.in.hdr.id; /* We respond with this id */ in chap_Input()
744 switch (chap->auth.in.hdr.code) { in chap_Input()
753 *chap->challenge.peer = alen; in chap_Input()
754 bp = mbuf_Read(bp, chap->challenge.peer + 1, alen); in chap_Input()
755 bp = auth_ReadName(&chap->auth, bp, len); in chap_Input()
758 ((chap->NTRespSent && IsAccepted(p->link.lcp.cfg.chap80lm)) || in chap_Input()
762 chap_ChallengeInit(&chap->auth); in chap_Input()
767 auth_StopTimer(&chap->auth); in chap_Input()
780 *ans = chap->auth.id; in chap_Input()
782 bp = auth_ReadName(&chap->auth, bp, len); in chap_Input()
802 switch (chap->auth.in.hdr.code) { in chap_Input()
805 if (*chap->auth.in.name) in chap_Input()
807 chapcodes[chap->auth.in.hdr.code], alen, in chap_Input()
808 chap->auth.in.name, in chap_Input()
810 lanman && chap->auth.in.hdr.code == CHAP_RESPONSE ? in chap_Input()
816 chapcodes[chap->auth.in.hdr.code], alen, in chap_Input()
818 lanman && chap->auth.in.hdr.code == CHAP_RESPONSE ? in chap_Input()
828 chapcodes[chap->auth.in.hdr.code], ans); in chap_Input()
831 chapcodes[chap->auth.in.hdr.code]); in chap_Input()
835 switch (chap->auth.in.hdr.code) { in chap_Input()
838 chap_StartChild(chap, bundle->cfg.auth.key + 1, in chap_Input()
841 chap_Respond(chap, bundle->cfg.auth.name, bundle->cfg.auth.key + in chap_Input()
851 name = chap->auth.in.name; in chap_Input()
857 chap->challenge.peer[0] = sizeof resp->PeerChallenge; in chap_Input()
858 memcpy(chap->challenge.peer + 1, resp->PeerChallenge, in chap_Input()
865 if (!radius_Authenticate(&bundle->radius, &chap->auth, in chap_Input()
866 chap->auth.in.name, ans, alen + 1, in chap_Input()
867 chap->challenge.local + 1, in chap_Input()
868 *chap->challenge.local)) in chap_Input()
869 chap_Failure(&chap->auth); in chap_Input()
887 if (chap_HaveAnotherGo(chap)) in chap_Input()
893 if (chap_HaveAnotherGo(chap)) in chap_Input()
903 char *myans = chap_BuildAnswer(name, key, chap->auth.id, in chap_Input()
904 chap->challenge.local in chap_Input()
907 chap->challenge.peer, in chap_Input()
908 chap->authresponse, lanman); in chap_Input()
928 chap_Success(&chap->auth); in chap_Input()
930 chap_Failure(&chap->auth); in chap_Input()
941 if (strncasecmp(ans, chap->authresponse, 42)) { in chap_Input()
944 " != ans: (%.42s)\n", chap->authresponse, ans); in chap_Input()