Closed Forsworns closed 2 years ago
I think sudo -E bash -c ...
will re-run your /root/.bashrc
and reset your PATH
. You should try sudo -E cargo ...
, or install through sudo rustup
.
I think
sudo -E bash -c ...
will re-run your/root/.bashrc
and reset yourPATH
. You should trysudo -E cargo ...
Tried sudo -E cargo ...
and the output is the same
Fine, maybe I need to reinstall the cargo and toolchains :(
It seems tedious to re-install system-wide cargo/rustup.
I change the /etc/passwd
file for user privilege escalation. By changing the user id and group id of the user with cargo installed to 0. The user gains root privilege without sudo
now. And the XDP program is successfully injected via cargo bpf
tool. Don't know if this is a good way. At least, it works without much suffering. :)
I work on WSL2 and it has support eBPF programs since version
5.10.74.3-microsoft-standard-WSL2
.As the
cargo-bpf
doc said:But my
cargo
is installed with rustup, which installs cargo in my user home. Therefore, I got errorsudo cargo: command not found
.I tried with
sudo -E bash -c "cargo bpf load -i eth0 target/bpf/programs/block_http.elf"
. But the error is the same.I also tried use
ip
to load xdp programs, as what is recommended in XDP tutorialHowever, it reminded me the elf file from redbpf did not has a xdp section and
PTR *mut xdp_md type_id=2 Invalid name
: