0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-12-22 09:14:15 +01:00

Fix SSH server on Windows when running as service

Closes #680
This commit is contained in:
Andrey Nering 2017-01-23 20:44:23 -02:00
parent 44d4863ecf
commit fda4476061
3 changed files with 14 additions and 4 deletions

View file

@ -8,17 +8,22 @@ package minwinsvc
import (
"os"
"strconv"
"sync"
"golang.org/x/sys/windows/svc"
)
var (
onExit func()
guard sync.Mutex
onExit func()
guard sync.Mutex
skip, _ = strconv.ParseBool(os.Getenv("SKIP_MINWINSVC"))
)
func init() {
if skip {
return
}
interactive, err := svc.IsAnInteractiveSession()
if err != nil {
panic(err)

View file

@ -22,13 +22,14 @@ import (
"code.gitea.io/git"
"code.gitea.io/gitea/modules/log"
_ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
"code.gitea.io/gitea/modules/user"
"github.com/Unknwon/com"
_ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
_ "github.com/go-macaron/cache/redis"
"github.com/go-macaron/session"
_ "github.com/go-macaron/session/redis" // redis plugin for store session
_ "github.com/kardianos/minwinsvc" // import minwinsvc for windows services
"gopkg.in/ini.v1"
"strk.kbt.io/projects/go/libravatar"
)

View file

@ -67,7 +67,11 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
args := []string{"serv", "key-" + keyID, "--config=" + setting.CustomConf}
log.Trace("SSH: Arguments: %v", args)
cmd := exec.Command(setting.AppPath, args...)
cmd.Env = append(os.Environ(), "SSH_ORIGINAL_COMMAND="+cmdName)
cmd.Env = append(
os.Environ(),
"SSH_ORIGINAL_COMMAND="+cmdName,
"SKIP_MINWINSVC=1",
)
stdout, err := cmd.StdoutPipe()
if err != nil {