grafana/pkg/infra/process/root_check.go
Marcus Andersson f3002931f4
PluginsCatalog: adding error information about disabled plugins. (#39171)
* added errors in plugin list.

* added error to details page.

* adding badge on details page.

* added some more tests.

* Renamed to disabled and will handle the scenario in the plugin catalog.

* Update public/app/features/plugins/admin/components/PluginDetailsDisabledError.tsx

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>

* fixing some nits

* added missing isDisabeld to the mock.

* adding tests to verify scenarios when plugin is disabled.

* fixed issue with formatting after file changed on GH.

Co-authored-by: Levente Balogh <balogh.levente.hu@gmail.com>
2021-09-20 09:08:00 +02:00

22 lines
382 B
Go

//go:build !windows
// +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
}