1 #include "ssh.h" 2 3 static int 4 authtisfn(Conn *c) 5 { 6 int fd, n; 7 char *chal, resp[256]; 8 Msg *m; 9 10 if(!c->interactive) 11 return -1; 12 13 debug(DBG_AUTH, "try TIS\n"); 14 sendmsg(allocmsg(c, SSH_CMSG_AUTH_TIS, 0)); 15 16 m = recvmsg(c, -1); 17 switch(m->type){ 18 default: 19 badmsg(m, SSH_SMSG_AUTH_TIS_CHALLENGE); 20 case SSH_SMSG_FAILURE: 21 free(m); 22 return -1; 23 case SSH_SMSG_AUTH_TIS_CHALLENGE: 24 break; 25 } 26 27 chal = getstring(m); 28 free(m); 29 30 if((fd = open("/dev/cons", ORDWR)) < 0) 31 error("can't open console"); 32 33 fprint(fd, "TIS Authentication\n%s", chal); 34 n = read(fd, resp, sizeof resp-1); 35 if(n < 0) 36 resp[0] = '\0'; 37 else 38 resp[n] = '\0'; 39 40 if(resp[0] == 0 || resp[0] == '\n') 41 return -1; 42 43 m = allocmsg(c, SSH_CMSG_AUTH_TIS_RESPONSE, 4+strlen(resp)); 44 putstring(m, resp); 45 sendmsg(m); 46 47 m = recvmsg(c, -1); 48 switch(m->type){ 49 default: 50 badmsg(m, 0); 51 case SSH_SMSG_SUCCESS: 52 free(m); 53 return 0; 54 case SSH_SMSG_FAILURE: 55 free(m); 56 return -1; 57 } 58 } 59 60 Auth authtis = 61 { 62 SSH_AUTH_TIS, 63 "tis", 64 authtisfn, 65 }; 66