aboutsummaryrefslogtreecommitdiff
path: root/internal/osutil
diff options
context:
space:
mode:
authorᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-02-22 20:46:16 +0800
committerᴜɴᴋɴᴡᴏɴ <u@gogs.io>2020-02-22 20:46:16 +0800
commit286fbc07e985d960209e8443a57e7f95efe60efd (patch)
treedd3d0d38081fa258751004472695c8fdc6885e43 /internal/osutil
parenta7e53b8134eefcbaa60a2755da8518dd08471a69 (diff)
conf: overhaul security settings
Diffstat (limited to 'internal/osutil')
-rw-r--r--internal/osutil/osutil.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/internal/osutil/osutil.go b/internal/osutil/osutil.go
index 6573cea0..656f2e2a 100644
--- a/internal/osutil/osutil.go
+++ b/internal/osutil/osutil.go
@@ -16,3 +16,13 @@ func IsFile(path string) bool {
}
return !f.IsDir()
}
+
+// CurrentUsername returns the current system user via environment variables.
+func CurrentUsername() string {
+ curUserName := os.Getenv("USER")
+ if len(curUserName) > 0 {
+ return curUserName
+ }
+
+ return os.Getenv("USERNAME")
+}