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

Improve the root privielge check when kyanos start #224

Closed
hengyoush opened this issue Dec 29, 2024 · 0 comments · Fixed by #242
Closed

Improve the root privielge check when kyanos start #224

hengyoush opened this issue Dec 29, 2024 · 0 comments · Fixed by #242
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@hengyoush
Copy link
Owner

hengyoush commented Dec 29, 2024

Is your feature request related to a problem? Please describe.
When kyanos start we check whether it has root privielge, but this was not accurate, we should check whether we have the CAP_BPF via capget syscall

Describe the solution you'd like

import (
	"golang.org/x/sys/unix"
)

hdr := unix.CapUserHeader{Version: unix.LINUX_CAPABILITY_VERSION_3}	
var data [2]unix.CapUserData
err := unix.Capget(&hdr, &data[0])
haveBpfCap := data[0].Permitted&unix.CAP_BPF != 0

Describe alternatives you've considered
If you have a better solution, feel free to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant