diff options
author | Unknwon <joe2010xtmf@163.com> | 2014-11-21 12:51:36 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2014-11-21 12:51:36 -0500 |
commit | ef275ebf62608b1bd2c7e48862e723cd822d93c2 (patch) | |
tree | 1ff4e8cd2a7b85b85b19d03855cb51e6327c3e8a /modules/ssh | |
parent | 22ab4fa1b0bdbea10979ae87568452b5bbf9b6af (diff) | |
download | gitea-ef275ebf62608b1bd2c7e48862e723cd822d93c2.tar.gz gitea-ef275ebf62608b1bd2c7e48862e723cd822d93c2.zip |
more on change avatar
Diffstat (limited to 'modules/ssh')
-rw-r--r-- | modules/ssh/ssh.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/modules/ssh/ssh.go b/modules/ssh/ssh.go index 814a3dd1f4..26169e0f3d 100644 --- a/modules/ssh/ssh.go +++ b/modules/ssh/ssh.go @@ -13,9 +13,8 @@ import ( "os/exec" "strings" - "code.google.com/p/go.crypto/ssh" - "github.com/Unknwon/com" + "golang.org/x/crypto/ssh" "github.com/gogits/gogs/modules/log" ) @@ -35,8 +34,11 @@ func handleServerConn(keyId string, chans <-chan ssh.NewChannel) { go func(in <-chan *ssh.Request) { defer channel.Close() for req := range in { - ok, payload := false, strings.TrimLeft(string(req.Payload), "\x00") + ok, payload := false, strings.TrimLeft(string(req.Payload), "\x00&") fmt.Println("Request:", req.Type, req.WantReply, payload) + if req.WantReply { + fmt.Println(req.Reply(true, nil)) + } switch req.Type { case "env": args := strings.Split(strings.Replace(payload, "\x00", "", -1), "\v") @@ -54,7 +56,7 @@ func handleServerConn(keyId string, chans <-chan ssh.NewChannel) { case "exec": os.Setenv("SSH_ORIGINAL_COMMAND", strings.TrimLeft(payload, "'(")) log.Info("Payload: %v", strings.TrimLeft(payload, "'(")) - cmd := exec.Command("/Users/jiahuachen/Applications/Go/src/github.com/gogits/gogs-ng/gogs-ng", "serv", "key-"+keyId) + cmd := exec.Command("/Users/jiahuachen/Applications/Go/src/github.com/gogits/gogs/gogs", "serv", "key-"+keyId) cmd.Stdout = channel cmd.Stdin = channel cmd.Stderr = channel.Stderr() @@ -65,7 +67,6 @@ func handleServerConn(keyId string, chans <-chan ssh.NewChannel) { } } fmt.Println("Done:", ok) - req.Reply(ok, nil) // BUG: Git on Mac seems not know this reply and hang? } fmt.Println("Done!!!") }(requests) @@ -101,7 +102,7 @@ func Listen(port string) { config := &ssh.ServerConfig{ PublicKeyCallback: func(conn ssh.ConnMetadata, key ssh.PublicKey) (*ssh.Permissions, error) { // keyCache[string(ssh.MarshalAuthorizedKey(key))] = 2 - return &ssh.Permissions{Extensions: map[string]string{"key-id": "2"}}, nil + return &ssh.Permissions{Extensions: map[string]string{"key-id": "1"}}, nil }, } |