2023-03-15 16:00:52 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
|
|
|
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2022-01-05 18:02:03 +00:00
|
|
|
//go:build !windows
|
2021-06-17 17:04:21 +00:00
|
|
|
|
|
|
|
package diagnose
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/fs"
|
2022-04-04 16:45:41 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/vault/helper/osutil"
|
2021-06-17 17:04:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// IsOwnedByRoot checks if a file is owned by root
|
|
|
|
func IsOwnedByRoot(info fs.FileInfo) bool {
|
2022-04-04 16:45:41 +00:00
|
|
|
if !osutil.FileUIDEqual(info, 0) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if !osutil.FileGIDEqual(info, 0) {
|
|
|
|
return false
|
2021-06-17 17:04:21 +00:00
|
|
|
}
|
2022-04-04 16:45:41 +00:00
|
|
|
return true
|
2021-06-17 17:04:21 +00:00
|
|
|
}
|