aboutsummaryrefslogtreecommitdiff
path: root/internal/conf/utils.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/conf/utils.go')
-rw-r--r--internal/conf/utils.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/conf/utils.go b/internal/conf/utils.go
index 5da34f0c..edead54a 100644
--- a/internal/conf/utils.go
+++ b/internal/conf/utils.go
@@ -10,6 +10,7 @@ import (
"github.com/pkg/errors"
+ "gogs.io/gogs/internal/osutil"
"gogs.io/gogs/internal/process"
)
@@ -34,3 +35,15 @@ func ensureAbs(path string) string {
}
return filepath.Join(WorkDir(), path)
}
+
+// CheckRunUser 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 CheckRunUser(runUser string) (string, bool) {
+ if IsWindowsRuntime() {
+ return "", true
+ }
+
+ currentUser := osutil.CurrentUsername()
+ return currentUser, runUser == currentUser
+}