Files
bpf-developer-tutorial/src/26-sudo/README_en.md
云微 deee286952 Add new post for 28 29 34 (#92)
* add 28 blog

* update test

* add 34

* Update test-libbpf.yml

* add link

* update 28

* add read only

* Update english version

* update 29

* update 29

* fix ci for 34
2024-01-19 23:48:42 +00:00

914 B

Using eBPF to add sudo user

The full source code for this article can be found at https://github.com/eunomia-bpf/bpf-developer-tutorial/tree/main/src/26-sudo

Compilation:

make

Usage:

sudo ./sudoadd --username lowpriv-user

This program allows a user with lower privileges to become root using sudo.

It works by intercepting sudo reading the /etc/sudoers file and overwriting the first line with <username> ALL=(ALL:ALL) NOPASSWD:ALL #. This tricks sudo into thinking that the user is allowed to become root. Other programs like cat or sudoedit are not affected, so the file remains unchanged and the user does not have these permissions. The # at the end of the line ensures that the rest of the line is treated as a comment, so it does not break the logic of the file.

References