authpasswd.c 729 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "ssh.h"
  2. static int
  3. authpasswordfn(Conn *c)
  4. {
  5. Msg *m;
  6. UserPasswd *up;
  7. up = auth_getuserpasswd(c->interactive ? auth_getkey : nil, "proto=pass service=ssh server=%q user=%q", c->host, c->user);
  8. if(up == nil){
  9. debug(DBG_AUTH, "getuserpasswd returned nothing (interactive=%d)\n", c->interactive);
  10. return -1;
  11. }
  12. debug(DBG_AUTH, "try using password from factotum\n");
  13. m = allocmsg(c, SSH_CMSG_AUTH_PASSWORD, 4+strlen(up->passwd));
  14. putstring(m, up->passwd);
  15. sendmsg(m);
  16. m = recvmsg(c, -1);
  17. switch(m->type){
  18. default:
  19. badmsg(m, 0);
  20. case SSH_SMSG_SUCCESS:
  21. free(m);
  22. return 0;
  23. case SSH_SMSG_FAILURE:
  24. free(m);
  25. return -1;
  26. }
  27. }
  28. Auth authpassword =
  29. {
  30. SSH_AUTH_PASSWORD,
  31. "password",
  32. authpasswordfn,
  33. };