]> source.dussan.org Git - gitea.git/commitdiff
Check run user
authorUnknown <joe2010xtmf@163.com>
Tue, 25 Mar 2014 10:52:56 +0000 (06:52 -0400)
committerUnknown <joe2010xtmf@163.com>
Tue, 25 Mar 2014 10:52:56 +0000 (06:52 -0400)
conf/app.ini
gogs.go
modules/base/conf.go
templates/user/delete.tmpl

index 809ea61c0762a884a01a9f9351ad37d58ccbf2c6..4c2398dd6874b4feae1bc9450dbee31198b18462 100644 (file)
@@ -1,8 +1,8 @@
 ; App name that shows on every page title
 APP_NAME = Gogs: Go Git Service
 APP_LOGO = img/favicon.png
-; !!MUST CHANGE TO YOUR USER NAME!!
-RUN_USER = lunny
+; Check it if you run locally
+RUN_USER = git
 ; Either "dev", "prod" or "test", default is "dev"
 RUN_MODE = dev
 
diff --git a/gogs.go b/gogs.go
index 93b7231b77b622b4cc5f016e73d06efbf5fef111..7ac699cc699cfa0151cc9e593017f280e652255e 100644 (file)
--- a/gogs.go
+++ b/gogs.go
@@ -7,7 +7,6 @@ package main
 
 import (
        "os"
-       // "os/user"
        "runtime"
 
        "github.com/codegangsta/cli"
@@ -27,21 +26,7 @@ func init() {
        runtime.GOMAXPROCS(runtime.NumCPU())
 }
 
-// func checkRunUser() bool {
-//     u, err := user.Current()
-//     if err != nil {
-//             // TODO: log
-//             return false
-//     }
-//     return u.Username == base.Cfg.MustValue("", "RUN_USER")
-// }
-
 func main() {
-       /*if !checkRunUser() {
-               println("The command should be run as", base.Cfg.MustValue("", "RUN_USER"))
-               return
-       }*/
-
        app := cli.NewApp()
        app.Name = "Gogs"
        app.Usage = "Go Git Service"
index d3122a533974997f93a7f2afb2e1a87a315be34e..c692ddc23f5a690a99cbdd2825d03c0a9422524f 100644 (file)
@@ -259,16 +259,11 @@ func NewConfigContext() {
        Cfg.BlockMode = false
 
        cfgPath = filepath.Join(workDir, "custom/conf/app.ini")
-       if !com.IsFile(cfgPath) {
-               fmt.Println("Custom configuration not found(custom/conf/app.ini)\n" +
-                       "Please create it and make your own configuration!")
-               os.Exit(2)
-
-       }
-
-       if err = Cfg.AppendFiles(cfgPath); err != nil {
-               fmt.Printf("Cannot load config file '%s'\n", cfgPath)
-               os.Exit(2)
+       if com.IsFile(cfgPath) {
+               if err = Cfg.AppendFiles(cfgPath); err != nil {
+                       fmt.Printf("Cannot load config file '%s'\n", cfgPath)
+                       os.Exit(2)
+               }
        }
 
        AppName = Cfg.MustValue("", "APP_NAME", "Gogs: Go Git Service")
@@ -276,7 +271,13 @@ func NewConfigContext() {
        AppUrl = Cfg.MustValue("server", "ROOT_URL")
        Domain = Cfg.MustValue("server", "DOMAIN")
        SecretKey = Cfg.MustValue("security", "SECRET_KEY")
+
        RunUser = Cfg.MustValue("", "RUN_USER")
+       curUser := os.Getenv("USERNAME")
+       if RunUser != curUser {
+               fmt.Printf("Expect user(%s) but current user is: %s\n", RunUser, curUser)
+               os.Exit(2)
+       }
 
        EnableHttpsClone = Cfg.MustBool("security", "ENABLE_HTTPS_CLONE", false)
 
index 46376672d4e980ed849dc92435723078888848a2..04c713eb65b5916f30b42284b43e795bd09f2f7b 100644 (file)
@@ -6,9 +6,9 @@
         <ul class="list-group">
             <li class="list-group-item"><a href="/user/setting">Account Profile</a></li>
             <li class="list-group-item"><a href="/user/setting/password">Password</a></li>
-            <li class="list-group-item"><a href="/user/setting/notification">Notifications</a></li>
+            <!-- <li class="list-group-item"><a href="/user/setting/notification">Notifications</a></li> -->
             <li class="list-group-item"><a href="/user/setting/ssh/">SSH Keys</a></li>
-            <li class="list-group-item"><a href="/user/setting/security">Security</a></li>
+            <!-- <li class="list-group-item"><a href="/user/setting/security">Security</a></li> -->
             <li class="list-group-item list-group-item-success"><a href="/user/delete">Delete Account</a></li>
         </ul>
     </div>