From a50b7b321d314034cea3771fe5a668af41e351a9 Mon Sep 17 00:00:00 2001 From: Federico Di Pierro Date: Mon, 11 Dec 2023 10:27:34 +0100 Subject: [PATCH] chore(pkg/driver): cleanup eBPF probe symlink in `Cleanup` method. Signed-off-by: Federico Di Pierro --- pkg/driver/type/bpf.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/driver/type/bpf.go b/pkg/driver/type/bpf.go index 3d4885af..5d976aba 100644 --- a/pkg/driver/type/bpf.go +++ b/pkg/driver/type/bpf.go @@ -43,7 +43,10 @@ func (b *bpf) String() string { return TypeBpf } -func (b *bpf) Cleanup(_ *output.Printer, _ string) error { +func (b *bpf) Cleanup(printer *output.Printer, driverName string) error { + symlinkPath := filepath.Join(homedir.Get(), ".falco", fmt.Sprintf("%s-bpf.o", driverName)) + printer.Logger.Info("Removing eBPF probe symlink", printer.Logger.Args("path", symlinkPath)) + _ = os.Remove(symlinkPath) return nil } @@ -51,7 +54,6 @@ func (b *bpf) Load(printer *output.Printer, src, driverName string, fallback boo if !fallback { symlinkPath := filepath.Join(homedir.Get(), ".falco", fmt.Sprintf("%s-bpf.o", driverName)) printer.Logger.Info("Symlinking eBPF probe", printer.Logger.Args("src", src, "dest", symlinkPath)) - _ = os.Remove(symlinkPath) err := os.Symlink(src, symlinkPath) if err == nil { printer.Logger.Info("eBPF probe symlinked")