mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
2378494a23
Mostly automated fixes from running: ``` go run golang.org/x/tools/go/analysis/passes/modernize/cmd/modernize@latest --fix ./... ``` But carefully reviewed, and several fixes reverted as they looked like they potentially could be less performant, and in a few cases due to bugs in the analyzer that changed semantics of the code. Will report these upstream. Mostly good fixes though! Signed-off-by: Anders Eknert <anders.eknert@apple.com>
25 lines
685 B
Go
25 lines
685 B
Go
//go:build !linux && !windows
|
|
|
|
// Copyright 2022 The OPA Authors. All rights reserved.
|
|
// Use of this source code is governed by an Apache2
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package runtime
|
|
|
|
import (
|
|
"os/user"
|
|
|
|
"github.com/open-policy-agent/opa/v1/logging"
|
|
)
|
|
|
|
// checkUserPrivileges could not be running in Docker, so we only warn
|
|
// if run as uid/gid 0.
|
|
func checkUserPrivileges(logger logging.Logger) {
|
|
usr, err := user.Current()
|
|
if err != nil {
|
|
logger.Debug("Failed to determine uid/gid of process owner")
|
|
} else if usr.Uid == "0" || usr.Gid == "0" {
|
|
logger.Warn("OPA running with uid or gid 0. Running OPA with root privileges is not recommended.")
|
|
}
|
|
}
|