mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	@@ -8,17 +8,22 @@ package minwinsvc
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
 | 
						"strconv"
 | 
				
			||||||
	"sync"
 | 
						"sync"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"golang.org/x/sys/windows/svc"
 | 
						"golang.org/x/sys/windows/svc"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	onExit func()
 | 
						onExit  func()
 | 
				
			||||||
	guard  sync.Mutex
 | 
						guard   sync.Mutex
 | 
				
			||||||
 | 
						skip, _ = strconv.ParseBool(os.Getenv("SKIP_MINWINSVC"))
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
 | 
						if skip {
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	interactive, err := svc.IsAnInteractiveSession()
 | 
						interactive, err := svc.IsAnInteractiveSession()
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		panic(err)
 | 
							panic(err)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,13 +22,14 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	"code.gitea.io/git"
 | 
						"code.gitea.io/git"
 | 
				
			||||||
	"code.gitea.io/gitea/modules/log"
 | 
						"code.gitea.io/gitea/modules/log"
 | 
				
			||||||
 | 
						_ "code.gitea.io/gitea/modules/minwinsvc" // import minwinsvc for windows services
 | 
				
			||||||
	"code.gitea.io/gitea/modules/user"
 | 
						"code.gitea.io/gitea/modules/user"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	"github.com/Unknwon/com"
 | 
						"github.com/Unknwon/com"
 | 
				
			||||||
	_ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
 | 
						_ "github.com/go-macaron/cache/memcache" // memcache plugin for cache
 | 
				
			||||||
	_ "github.com/go-macaron/cache/redis"
 | 
						_ "github.com/go-macaron/cache/redis"
 | 
				
			||||||
	"github.com/go-macaron/session"
 | 
						"github.com/go-macaron/session"
 | 
				
			||||||
	_ "github.com/go-macaron/session/redis" // redis plugin for store 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"
 | 
						"gopkg.in/ini.v1"
 | 
				
			||||||
	"strk.kbt.io/projects/go/libravatar"
 | 
						"strk.kbt.io/projects/go/libravatar"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,7 +67,11 @@ func handleServerConn(keyID string, chans <-chan ssh.NewChannel) {
 | 
				
			|||||||
					args := []string{"serv", "key-" + keyID, "--config=" + setting.CustomConf}
 | 
										args := []string{"serv", "key-" + keyID, "--config=" + setting.CustomConf}
 | 
				
			||||||
					log.Trace("SSH: Arguments: %v", args)
 | 
										log.Trace("SSH: Arguments: %v", args)
 | 
				
			||||||
					cmd := exec.Command(setting.AppPath, 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()
 | 
										stdout, err := cmd.StdoutPipe()
 | 
				
			||||||
					if err != nil {
 | 
										if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user