@@ -30,6 +30,8 @@ import (
30
30
31
31
"github.com/unknwon/com"
32
32
gossh "golang.org/x/crypto/ssh"
33
+ "golang.org/x/text/cases"
34
+ "golang.org/x/text/language"
33
35
ini "gopkg.in/ini.v1"
34
36
)
35
37
@@ -637,7 +639,7 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
637
639
}
638
640
UnixSocketPermissionRaw := sec .Key ("UNIX_SOCKET_PERMISSION" ).MustString ("666" )
639
641
UnixSocketPermissionParsed , err := strconv .ParseUint (UnixSocketPermissionRaw , 8 , 32 )
640
- if err != nil || UnixSocketPermissionParsed > 0777 {
642
+ if err != nil || UnixSocketPermissionParsed > 0o777 {
641
643
log .Fatal ("Failed to parse unixSocketPermission: %s" , UnixSocketPermissionRaw )
642
644
}
643
645
@@ -793,16 +795,16 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
793
795
SSH .AuthorizedPrincipalsAllow , SSH .AuthorizedPrincipalsEnabled = parseAuthorizedPrincipalsAllow (sec .Key ("SSH_AUTHORIZED_PRINCIPALS_ALLOW" ).Strings ("," ))
794
796
795
797
if ! SSH .Disabled && ! SSH .StartBuiltinServer {
796
- if err := os .MkdirAll (SSH .RootPath , 0700 ); err != nil {
798
+ if err := os .MkdirAll (SSH .RootPath , 0o700 ); err != nil {
797
799
log .Fatal ("Failed to create '%s': %v" , SSH .RootPath , err )
798
- } else if err = os .MkdirAll (SSH .KeyTestPath , 0644 ); err != nil {
800
+ } else if err = os .MkdirAll (SSH .KeyTestPath , 0o644 ); err != nil {
799
801
log .Fatal ("Failed to create '%s': %v" , SSH .KeyTestPath , err )
800
802
}
801
803
802
804
if len (trustedUserCaKeys ) > 0 && SSH .AuthorizedPrincipalsEnabled {
803
805
fname := sec .Key ("SSH_TRUSTED_USER_CA_KEYS_FILENAME" ).MustString (filepath .Join (SSH .RootPath , "gitea-trusted-user-ca-keys.pem" ))
804
806
if err := os .WriteFile (fname ,
805
- []byte (strings .Join (trustedUserCaKeys , "\n " )), 0600 ); err != nil {
807
+ []byte (strings .Join (trustedUserCaKeys , "\n " )), 0o600 ); err != nil {
806
808
log .Fatal ("Failed to create '%s': %v" , fname , err )
807
809
}
808
810
}
@@ -943,8 +945,9 @@ func loadFromConf(allowEmpty bool, extraConfig string) {
943
945
// The following is a purposefully undocumented option. Please do not run Gitea as root. It will only cause future headaches.
944
946
// Please don't use root as a bandaid to "fix" something that is broken, instead the broken thing should instead be fixed properly.
945
947
unsafeAllowRunAsRoot := Cfg .Section ("" ).Key ("I_AM_BEING_UNSAFE_RUNNING_AS_ROOT" ).MustBool (false )
946
- RunMode = Cfg .Section ("" ).Key ("RUN_MODE" ).MustString ("prod" )
947
- IsProd = strings .EqualFold (RunMode , "prod" )
948
+ RunMode = Cfg .Section ("" ).Key ("RUN_MODE" ).MustString ("Prod" )
949
+ RunMode = cases .Title (language .English ).String (strings .ToLower (RunMode ))
950
+ IsProd = RunMode == "Prod"
948
951
// Does not check run user when the install lock is off.
949
952
if InstallLock {
950
953
currentUser , match := IsRunUserMatchCurrentUser (RunUser )
@@ -1074,7 +1077,7 @@ func loadInternalToken(sec *ini.Section) string {
1074
1077
}
1075
1078
switch tempURI .Scheme {
1076
1079
case "file" :
1077
- fp , err := os .OpenFile (tempURI .RequestURI (), os .O_RDWR , 0600 )
1080
+ fp , err := os .OpenFile (tempURI .RequestURI (), os .O_RDWR , 0o600 )
1078
1081
if err != nil {
1079
1082
log .Fatal ("Failed to open InternalTokenURI (%s): %v" , uri , err )
1080
1083
}
0 commit comments