authtis.c 1013 B

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