From 7106c08852a5e6ab35753e9a8fde0bff95c717cc Mon Sep 17 00:00:00 2001 From: li-long315 Date: Sun, 25 Jun 2023 09:36:19 +0800 Subject: [PATCH] Check permissions and fetch necessary BTF for CO-RE --- observation/src/ttysnoop/ttysnoop.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/observation/src/ttysnoop/ttysnoop.c b/observation/src/ttysnoop/ttysnoop.c index 47a23a64..fe87d5f7 100644 --- a/observation/src/ttysnoop/ttysnoop.c +++ b/observation/src/ttysnoop/ttysnoop.c @@ -112,6 +112,15 @@ int main(int argc, char *argv[]) err = argp_parse(&argp, argc, argv, 0, NULL, NULL); if (err) return err; + + if (!bpf_is_root()) + return 1; + + err = ensure_core_btf(&open_opts); + if (err) { + warning("Failed to fetch necessary BTF for CO-RE: %s\n", strerror(-err)); + return 1; + } return err != 0; } -- Gitee