static void incoming(Conn *cp, If *ifc, Pkt *p) { int i; Block *bp; Pkt *np; /* ack it no matter what its sequence number */ bp = sethdr(ifc, p->src, &np, 0); np->type = Tack; np->seq = p->seq; np->conn = cp->cno; np->len = 0; trace(bp); ifc->d->bwrite(ifc->dc, bp, 0); if(cp->state == Cunused){ /* connection */ discover(ifc, p); return; } if(p->seq == cp->rcvseq) return; cp->rcvseq = p->seq; if(cp->state == Copen){ for (i = 0; i < p->len; i++) kbdcr2nl(nil, (char)p->data[i]); }else if(cp->state == Clogin) checkpw(cp, (char *)p->data, p->len); }
void readpw() { char userpw[256]; int c, r = 1, i = 0; WINDOW *winp; winp = newwin(0,0,0,0); while((c = getch()) != ERR) switch(c) { case '\n': userpw[i] = '\0'; if(!checkpw(userpw)) return; case KEY_ESCAPE: i = 0; wbkgd(winp, ' ' | COLOR_PAIR(0)); wrefresh(winp); break; case KEY_BACKSPACE: if(i > 0) --i; break; default: r = (r + (rand() % (num_colors - 1))) % num_colors + 1; wbkgd(winp, ' ' | COLOR_PAIR(r)); wrefresh(winp); userpw[i] = c; if(i < 254) ++i; else i = 0; break; } delwin(winp); }
int checkpw_internal( const struct passwd* pw, const char* password ) { return checkpw(pw->pw_name, password); }