Unverified Commit b4ed7c7a authored by Eric_Lee's avatar Eric_Lee Committed by GitHub

Merge pull request #144 from jumpserver/dev_bugfix

[Bugfix] fix telnet login connect bug
parents 4ca19af8 2843aeaa
...@@ -27,7 +27,7 @@ const ( ...@@ -27,7 +27,7 @@ const (
SAG = 3 SAG = 3
ECHO = 1 ECHO = 1
loginRegs = "(?i)login:?\\s*$|username:?\\s*$|name:?\\s*$|用户名:?\\s*$|账\\s*号:?\\s*$" loginRegs = "(?i)login:?\\s*$|username:?\\s*$|name:?\\s*$|用户名:?\\s*$|账\\s*号:?\\s*$|user:?\\s*$"
passwordRegs = "(?i)Password:?\\s*$|ssword:?\\s*$|passwd:?\\s*$|密\\s*码:?\\s*$" passwordRegs = "(?i)Password:?\\s*$|ssword:?\\s*$|passwd:?\\s*$|密\\s*码:?\\s*$"
FailedRegs = "(?i)incorrect|failed|失败|错误" FailedRegs = "(?i)incorrect|failed|失败|错误"
DefaultSuccessRegs = "(?i)Last\\s*login|success|成功|#|>|\\$" DefaultSuccessRegs = "(?i)Last\\s*login|success|成功|#|>|\\$"
...@@ -122,11 +122,11 @@ func (tc *ServerTelnetConnection) login(data []byte) AuthStatus { ...@@ -122,11 +122,11 @@ func (tc *ServerTelnetConnection) login(data []byte) AuthStatus {
return AuthFailed return AuthFailed
} else if usernamePattern.Match(data) { } else if usernamePattern.Match(data) {
_, _ = tc.conn.Write([]byte(tc.SystemUser.Username + "\r\n")) _, _ = tc.conn.Write([]byte(tc.SystemUser.Username + "\r\n"))
logger.Debug("Username pattern match: ", data) logger.Debugf("Username pattern match: %s", data)
return AuthPartial return AuthPartial
} else if passwordPattern.Match(data) { } else if passwordPattern.Match(data) {
_, _ = tc.conn.Write([]byte(tc.SystemUser.Password + "\r\n")) _, _ = tc.conn.Write([]byte(tc.SystemUser.Password + "\r\n"))
logger.Debug("Password pattern ", data) logger.Debugf("Password pattern: %s", data)
return AuthPartial return AuthPartial
} else if successPattern.Match(data) { } else if successPattern.Match(data) {
return AuthSuccess return AuthSuccess
...@@ -169,7 +169,7 @@ func (tc *ServerTelnetConnection) Connect(h, w int, term string) (err error) { ...@@ -169,7 +169,7 @@ func (tc *ServerTelnetConnection) Connect(h, w int, term string) (err error) {
return return
} }
if tc.SystemUser.Password == ""{ if tc.SystemUser.Password == "" {
info := service.GetSystemUserAssetAuthInfo(tc.SystemUser.ID, asset.ID) info := service.GetSystemUserAssetAuthInfo(tc.SystemUser.ID, asset.ID)
tc.SystemUser.Password = info.Password tc.SystemUser.Password = info.Password
tc.SystemUser.PrivateKey = info.PrivateKey tc.SystemUser.PrivateKey = info.PrivateKey
...@@ -193,7 +193,7 @@ func (tc *ServerTelnetConnection) Connect(h, w int, term string) (err error) { ...@@ -193,7 +193,7 @@ func (tc *ServerTelnetConnection) Connect(h, w int, term string) (err error) {
case AuthSuccess: case AuthSuccess:
return nil return nil
case AuthFailed: case AuthFailed:
return errors.New("Failed login") return errors.New("failed login")
default: default:
continue continue
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment