Skip to content

Commit e7c3be5

Browse files
authored
Merge pull request #736 from andreynering/fix-windows-ssh
Fix SSH server on Windows when running as service
2 parents da1b616 + 2009f4c commit e7c3be5

File tree

8 files changed

+15
-11
lines changed

8 files changed

+15
-11
lines changed

vendor/github.com/kardianos/minwinsvc/minwinsvc.go renamed to modules/minwinsvc/minwinsvc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a zlib-style
33
// license that can be found in the LICENSE file.package service
44

5-
// Minimal non-invasive windows only service stub.
5+
// Package minwinsvc is a minimal non-invasive windows only service stub.
66
//
77
// Import to allow running as a windows service.
88
// import _ "github.com/kardianos/minwinsvc"

vendor/github.com/kardianos/minwinsvc/svc_windows.go renamed to modules/minwinsvc/svc_windows.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,22 @@ package minwinsvc
88

99
import (
1010
"os"
11+
"strconv"
1112
"sync"
1213

1314
"golang.org/x/sys/windows/svc"
1415
)
1516

1617
var (
17-
onExit func()
18-
guard sync.Mutex
18+
onExit func()
19+
guard sync.Mutex
20+
skip, _ = strconv.ParseBool(os.Getenv("SKIP_MINWINSVC"))
1921
)
2022

2123
func init() {
24+
if skip {
25+
return
26+
}
2227
interactive, err := svc.IsAnInteractiveSession()
2328
if err != nil {
2429
panic(err)

modules/setting/setting.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ import (
2222

2323
"code.gitea.io/git"
2424
"code.gitea.io/gitea/modules/log"
25+
_ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
2526
"code.gitea.io/gitea/modules/user"
27+
2628
"github.com/Unknwon/com"
2729
_ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
2830
_ "github.com/go-macaron/cache/redis"
2931
"github.com/go-macaron/session"
3032
_ "github.com/go-macaron/session/redis" // redis plugin for store session
31-
_ "github.com/kardianos/minwinsvc" // import minwinsvc for windows services
3233
"gopkg.in/ini.v1"
3334
"strk.kbt.io/projects/go/libravatar"
3435
)

modules/ssh/ssh.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,11 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
6767
args := []string{"serv", "key-" + keyID, "--config=" + setting.CustomConf}
6868
log.Trace("SSH: Arguments: %v", args)
6969
cmd := exec.Command(setting.AppPath, args...)
70-
cmd.Env = append(os.Environ(), "SSH_ORIGINAL_COMMAND="+cmdName)
70+
cmd.Env = append(
71+
os.Environ(),
72+
"SSH_ORIGINAL_COMMAND="+cmdName,
73+
"SKIP_MINWINSVC=1",
74+
)
7175

7276
stdout, err := cmd.StdoutPipe()
7377
if err != nil {

vendor/vendor.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -514,12 +514,6 @@
514514
"revision": "b2c7a7da5b2995941048f60146e67702a292e468",
515515
"revisionTime": "2016-02-12T04:00:40Z"
516516
},
517-
{
518-
"checksumSHA1": "/dBJ2h8Jo359deiC5GQ8ZYzX8M8=",
519-
"path": "github.com/kardianos/minwinsvc",
520-
"revision": "cad6b2b879b0970e4245a20ebf1a81a756e2bb70",
521-
"revisionTime": "2015-11-22T16:33:09Z"
522-
},
523517
{
524518
"checksumSHA1": "fh+CcgeUUsnuwSORHYWg0ycbp+4=",
525519
"path": "github.com/klauspost/compress/flate",

0 commit comments

Comments
 (0)