mirror of https://github.com/grafana/grafana
Chore: Add WARN log if grafana server process is running with elevated privileges (#35205)
* warn on linux * add warning for grpc plugins * add windows support * update go.mod * reorganize imports * update naming * remove Windows logic * simplify and add check for when UID and EUID don't match * fix build * tidy go.mod * feedback * cleanup + migratepull/39150/head
parent
40267f5ea0
commit
1a71f0fe13
@ -0,0 +1,5 @@ |
||||
package process |
||||
|
||||
func IsRunningWithElevatedPrivileges() (bool, error) { |
||||
return elevatedPrivilegesCheck() |
||||
} |
@ -0,0 +1,20 @@ |
||||
// +build !windows
|
||||
|
||||
package process |
||||
|
||||
import ( |
||||
"fmt" |
||||
"os" |
||||
"os/user" |
||||
) |
||||
|
||||
func elevatedPrivilegesCheck() (bool, error) { |
||||
u, err := user.Current() |
||||
if err != nil { |
||||
return false, fmt.Errorf("could not get current OS user to detect process privileges") |
||||
} |
||||
|
||||
return (u != nil && u.Username == "root") || |
||||
os.Geteuid() != os.Getuid() || |
||||
os.Geteuid() == 0, nil |
||||
} |
@ -0,0 +1,8 @@ |
||||
// +build windows
|
||||
|
||||
package process |
||||
|
||||
func elevatedPrivilegesCheck() (bool, error) { |
||||
// TODO implement Windows process root check
|
||||
return false, nil |
||||
} |
Loading…
Reference in new issue