teleport/lib/cgroup
Mike Jensen 4cba417e80
Careful handling when loading files (#31721)
* Careful handling when loading files

This commit attempts to provide a common API so that the decision of when to follow symlinks is a conscious decision.
Because Teleport (particularly the agent) runs in a privilege context, there is risk that following symlinks may allow information disclosure.

After review of the cases covered in this commit (and some additional cases where this API was not a natural fit), this does not appear to be a broad problem.  This commit however does fix the one known flaw described in the issue https://github.com/gravitational/teleport-private/issues/1009

* Apply PR feedback to rename OpenFile

* fs.go: Fix symlink evaluation

* fs.go: Fix for rebuilding absolute paths in symlink check

* fs_test.go: Add symlink testing

* Apply suggestions from code review

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>

* fs_test.go: Fix build for err reference

* fs.go: Apply PR feedback and consider Hardlinks

After PR discussion it was highlighted that MacOS does not guard against hardlinks in the same way linux does.  For that reason this implementation has been updated with OS conditional logic to validate against hardlinks.

* fs.go: Switch loop to range over components instead of index

* Minor improvements from PR feedback

* fs_test.go: Test public OpenFile API's and include OS specific validation

* Fix windows build

Make hardlink count lookup code build conditional to avoid undefined syscall.Stat_t.

* utils.getHardLinkCount result order update from PR feedback

* fs_windows.go: Comment improvements from PR feedback

* fs: Fix build for OSX

* Disable lint error due to unecessary cast on linux

---------

Co-authored-by: Krzysztof Skrzętnicki <krzysztof.skrzetnicki@goteleport.com>
2023-09-15 14:44:31 +00:00
..
cgroup.go Careful handling when loading files (#31721) 2023-09-15 14:44:31 +00:00
cgroup_test.go Don't unmount cgroup2 when restarting (#26610) 2023-05-22 19:42:12 +00:00