forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
96 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
receiver/awscontainerinsightreceiver/internal/efa/permissionscheck_linux.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !windows | ||
// +build !windows | ||
|
||
package efa | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"os" | ||
"syscall" | ||
) | ||
|
||
func checkPermissions(info os.FileInfo) (bool, error) { | ||
stat, ok := info.Sys().(*syscall.Stat_t) | ||
if !ok { | ||
return false, errors.New("couldn't read permissions") | ||
} | ||
|
||
if stat.Uid != 0 { | ||
return false, fmt.Errorf("not owned by root, owned by uid %d", stat.Uid) | ||
} | ||
perms := info.Mode().Perm() | ||
if perms&0002 != 0 { | ||
return false, fmt.Errorf("writeable by anyone, permissions: %s", perms.String()) | ||
} | ||
|
||
return true, nil | ||
} |
11 changes: 11 additions & 0 deletions
11
receiver/awscontainerinsightreceiver/internal/efa/permissionscheck_windows.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build windows | ||
// +build windows | ||
|
||
package efa | ||
|
||
func checkPermissions(info os.FileInfo) (bool, error) { | ||
return false, errors.New("not implemented on Windows") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...erinsightreceiver/internal/stores/kubeletutil/podresourcesclientpermissionscheck_linux.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build !windows | ||
// +build !windows | ||
|
||
package kubeletutil | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"syscall" | ||
) | ||
|
||
func checkPodResourcesSocketPermissions(info os.FileInfo) error { | ||
stat, ok := info.Sys().(*syscall.Stat_t) | ||
if !ok { | ||
return fmt.Errorf("couldn't check permissions") | ||
} | ||
|
||
if stat.Uid != 0 { | ||
return fmt.Errorf("owned by %d, not root", stat.Uid) | ||
} | ||
perms := info.Mode().Perm() | ||
if perms&0002 != 0 { | ||
return fmt.Errorf("writeable by anyone - permissions: %s", perms) | ||
} | ||
if info.Mode()&os.ModeSocket == 0 { | ||
return fmt.Errorf("not a socket - mode: %s", info.Mode()) | ||
} | ||
|
||
return nil | ||
} |
15 changes: 15 additions & 0 deletions
15
...insightreceiver/internal/stores/kubeletutil/podresourcesclientpermissionscheck_windows.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//go:build windows | ||
// +build windows | ||
|
||
package kubeletutil | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func checkPodResourcesSocketPermissions(info os.FileInfo) error { | ||
return errors.New("not implemented on Windows") | ||
} |