Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid heavy calls when reading /proc #39

Merged
merged 2 commits into from Feb 3, 2020

Conversation

a-palchikov
Copy link
Contributor

On systems with SELinux in enforcing mode, this will unnecessarily require broader access to the whole of /proc (newfstatat or lstat which translated to SELinux getattr permission as opposed to a simple getdents64 syscall which is less pervasive).
Reading just the names is enough though to determine whether an entry looks like a pid directory.

simple numeric name check should suffice. Otherwise, it is pretty
problematic to query processes on systems with SELinux in enforcing mode
as it is complicated to open access to _all_ files inside proc.
The reason this catch-all access is required is that with os.Readdir it
needs to lstat each entry to return os.FileInfo and this requires
additional permissions on each disperate file type inside /proc which is
not easy to catch with an attribute (as it is with processes).
Update process fetcher to support SELinux-enabled systems.
@mitchellh mitchellh merged commit e4db5bf into mitchellh:master Feb 3, 2020
@mitchellh
Copy link
Owner

This looks good thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants