diff options
| author | forsyth <forsyth@vitanuova.com> | 2011-01-17 10:45:22 +0000 |
|---|---|---|
| committer | forsyth <forsyth@vitanuova.com> | 2011-01-17 10:45:22 +0000 |
| commit | 9e6910dc0c747c8f30b87f6482f4eadb48ad6654 (patch) | |
| tree | 4f835b35913acfb115b15ea4f1c6af40fd77ab54 /appl/cmd/ssh/authpassword.b | |
| parent | 16501eaf1cb642b80d7fa0236407a27aecb35b02 (diff) | |
emu/Nt/ipif.c
Diffstat (limited to 'appl/cmd/ssh/authpassword.b')
| -rw-r--r-- | appl/cmd/ssh/authpassword.b | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/appl/cmd/ssh/authpassword.b b/appl/cmd/ssh/authpassword.b new file mode 100644 index 00000000..1a149117 --- /dev/null +++ b/appl/cmd/ssh/authpassword.b @@ -0,0 +1,68 @@ +implement Auth; + +include "sys.m"; + sys: Sys; + +include "ipints.m"; + ipints: IPints; + IPint: import ipints; + +include "crypt.m"; + crypt: Crypt; # TO DO: needed to avoid compiler error + +include "factotum.m"; + factotum: Factotum; + +include "sshio.m"; + sshio: Sshio; + Conn, Msg: import sshio; + +id(): int +{ + return SSH_AUTH_PASSWORD; +} + +init(mod: Sshio) +{ + sys = load Sys Sys->PATH; + sshio = mod; +} + +firstmsg(): int +{ + return SSH_CMSG_AUTH_PASSWORD; +} + +authsrv(c: ref Conn, m: ref Msg): ref AuthInfo +{ + pass := m.getstring(); +# return auth_userpasswd(c.user, pass); + return ref AuthInfo(c.user, nil); # TO DO: +} + +auth(c: ref Conn): int +{ + if(factotum == nil) + factotum = load Factotum Factotum->PATH; + (user, pass) := factotum->getuserpasswd(sys->sprint("proto=pass service=ssh server=%q user=%q", c.host, c.user)); + if(user == nil){ + sshio->debug(DBG_AUTH, "getuserpasswd failed"); + return -1; + } + + sshio->debug(DBG_AUTH, "try using password from factotum\n"); + m := Msg.mk(SSH_CMSG_AUTH_PASSWORD, 4+Sys->UTFmax*len pass); + m.putstring(pass); + c.out <-= m; + + m = sshio->recvmsg(c, -1); + case m.mtype { + SSH_SMSG_SUCCESS => + return 0; + SSH_SMSG_FAILURE => + return -1; + * => + sshio->badmsg(m, 0, nil); + return -1; + } +} |
