]> source.dussan.org Git - gitea.git/commitdiff
#3158 skip RUN_USER check on Windows
authorUnknwon <u@gogs.io>
Wed, 10 Aug 2016 00:41:18 +0000 (17:41 -0700)
committerUnknwon <u@gogs.io>
Wed, 10 Aug 2016 00:41:18 +0000 (17:41 -0700)
README.md
gogs.go
modules/setting/setting.go
routers/install.go
templates/.VERSION

index 76c3624969bfe4842a0fa0bd7dd254b5d26a909a..dd4255da2ff1f2d85bfcc9a937aeaeb4e6e51359 100644 (file)
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
 
 ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
 
-##### Current tip version: 0.9.69 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
+##### Current tip version: 0.9.70 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
 
 | Web | UI  | Preview  |
 |:-------------:|:-------:|:-------:|
diff --git a/gogs.go b/gogs.go
index 09d8590c6c60c2234b543e899d525011ca5950cc..092e663e443438fe883e509dd1f6dee361a956fd 100644 (file)
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
        "github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.9.69.0808"
+const APP_VER = "0.9.70.0808"
 
 func init() {
        runtime.GOMAXPROCS(runtime.NumCPU())
index aa618ad65c09b104636b5a88c783d5897d6b1227..a56c4824e9be306b0d0aac978b6daf83a62d8b4a 100644 (file)
@@ -285,6 +285,19 @@ func forcePathSeparator(path string) {
        }
 }
 
+// IsRunUserMatchCurrentUser returns false if configured run user does not match
+// actual user that runs the app. The first return value is the actual user name.
+// This check is ignored under Windows since SSH remote login is not the main
+// method to login on Windows.
+func IsRunUserMatchCurrentUser(runUser string) (string, bool) {
+       if IsWindows {
+               return "", true
+       }
+
+       currentUser := user.CurrentUsername()
+       return currentUser, runUser == currentUser
+}
+
 // NewContext initializes configuration context.
 // NOTE: do not print any log except error.
 func NewContext() {
@@ -431,10 +444,12 @@ func NewContext() {
        }[Cfg.Section("time").Key("FORMAT").MustString("RFC1123")]
 
        RunUser = Cfg.Section("").Key("RUN_USER").String()
-       curUser := user.CurrentUsername()
        // Does not check run user when the install lock is off.
-       if InstallLock && RunUser != curUser {
-               log.Fatal(4, "Expect user(%s) but current user is: %s", RunUser, curUser)
+       if InstallLock {
+               currentUser, match := IsRunUserMatchCurrentUser(RunUser)
+               if !match {
+                       log.Fatal(4, "Expect user '%s' but current user is: %s", RunUser, currentUser)
+               }
        }
 
        // Determine and create root git repository path.
index 8b96ff82542df5f4f7002ab406fb2a9ed87f0612..75f38a7931a1ce4dc36e2e0ddd65b0617b1e37f2 100644 (file)
@@ -252,11 +252,10 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
                return
        }
 
-       // Check run user.
-       curUser := user.CurrentUsername()
-       if form.RunUser != curUser {
+       currentUser, match := setting.IsRunUserMatchCurrentUser(form.RunUser)
+       if !match {
                ctx.Data["Err_RunUser"] = true
-               ctx.RenderWithErr(ctx.Tr("install.run_user_not_match", form.RunUser, curUser), INSTALL, &form)
+               ctx.RenderWithErr(ctx.Tr("install.run_user_not_match", form.RunUser, currentUser), INSTALL, &form)
                return
        }
 
index ec9912cd1e75ad05ef784760d2ecca0532eee475..211c83f959a61839d9d8f021aceb995c73777d2c 100644 (file)
@@ -1 +1 @@
-0.9.69.0808
\ No newline at end of file
+0.9.70.0808
\ No newline at end of file