diff --git a/user/probe_gnutls.go b/user/probe_gnutls.go index 7a9d66a3c..06a71b066 100644 --- a/user/probe_gnutls.go +++ b/user/probe_gnutls.go @@ -10,6 +10,7 @@ import ( "golang.org/x/sys/unix" "log" "math" + "os" ) type MGnutlsProbe struct { @@ -46,7 +47,10 @@ func (this *MGnutlsProbe) start() error { } // setup the managers - this.setupManagers() + err = this.setupManagers() + if err != nil { + return errors.Wrap(err, "tls module couldn't find binPath.") + } // initialize the bootstrap manager if err := this.bpfManager.InitWithOptions(bytes.NewReader(byteBuf), this.bpfManagerOptions); err != nil { @@ -93,7 +97,7 @@ func (e *MGnutlsProbe) constantEditor() []manager.ConstantEditor { return editor } -func (this *MGnutlsProbe) setupManagers() { +func (this *MGnutlsProbe) setupManagers() error { var binaryPath string switch this.conf.(*GnutlsConfig).elfType { case ELF_TYPE_BIN: @@ -105,6 +109,11 @@ func (this *MGnutlsProbe) setupManagers() { binaryPath = "/lib/x86_64-linux-gnu/libgnutls.so.30" } + _, err := os.Stat(binaryPath) + if err != nil { + return err + } + this.logger.Printf("HOOK type:%d, binrayPath:%s\n", this.conf.(*GnutlsConfig).elfType, binaryPath) this.bpfManager = &manager.Manager{ @@ -158,6 +167,7 @@ func (this *MGnutlsProbe) setupManagers() { // 填充 RewriteContants 对应map ConstantEditors: this.constantEditor(), } + return nil } func (this *MGnutlsProbe) DecodeFun(em *ebpf.Map) (IEventStruct, bool) { diff --git a/user/probe_openssl.go b/user/probe_openssl.go index 6c87fc53f..065ad0032 100644 --- a/user/probe_openssl.go +++ b/user/probe_openssl.go @@ -10,6 +10,7 @@ import ( "golang.org/x/sys/unix" "log" "math" + "os" ) type MOpenSSLProbe struct { @@ -46,7 +47,10 @@ func (this *MOpenSSLProbe) start() error { } // setup the managers - this.setupManagers() + err = this.setupManagers() + if err != nil { + return errors.Wrap(err, "tls module couldn't find binPath.") + } // initialize the bootstrap manager if err := this.bpfManager.InitWithOptions(bytes.NewReader(byteBuf), this.bpfManagerOptions); err != nil { @@ -93,7 +97,7 @@ func (e *MOpenSSLProbe) constantEditor() []manager.ConstantEditor { return editor } -func (this *MOpenSSLProbe) setupManagers() { +func (this *MOpenSSLProbe) setupManagers() error { var binaryPath string switch this.conf.(*OpensslConfig).elfType { case ELF_TYPE_BIN: @@ -105,6 +109,11 @@ func (this *MOpenSSLProbe) setupManagers() { binaryPath = "/lib/x86_64-linux-gnu/libssl.so.1.1" } + _, err := os.Stat(binaryPath) + if err != nil { + return err + } + this.logger.Printf("HOOK type:%d, binrayPath:%s\n", this.conf.(*OpensslConfig).elfType, binaryPath) this.bpfManager = &manager.Manager{ @@ -184,6 +193,7 @@ func (this *MOpenSSLProbe) setupManagers() { // 填充 RewriteContants 对应map ConstantEditors: this.constantEditor(), } + return nil } func (this *MOpenSSLProbe) DecodeFun(em *ebpf.Map) (IEventStruct, bool) {