Skip to content

Commit

Permalink
1, fix tls module run codition,one of openssl/gnutls/(nspr|nss) file …
Browse files Browse the repository at this point in the history
…existed.

Signed-off-by: CFC4N <cfc4n.cs@gmail.com>
  • Loading branch information
cfc4n committed Mar 22, 2022
1 parent cd6172a commit 7f120bb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 12 additions & 2 deletions user/probe_gnutls.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"golang.org/x/sys/unix"
"log"
"math"
"os"
)

type MGnutlsProbe struct {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand All @@ -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{
Expand Down Expand Up @@ -158,6 +167,7 @@ func (this *MGnutlsProbe) setupManagers() {
// 填充 RewriteContants 对应map
ConstantEditors: this.constantEditor(),
}
return nil
}

func (this *MGnutlsProbe) DecodeFun(em *ebpf.Map) (IEventStruct, bool) {
Expand Down
14 changes: 12 additions & 2 deletions user/probe_openssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"golang.org/x/sys/unix"
"log"
"math"
"os"
)

type MOpenSSLProbe struct {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand All @@ -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{
Expand Down Expand Up @@ -184,6 +193,7 @@ func (this *MOpenSSLProbe) setupManagers() {
// 填充 RewriteContants 对应map
ConstantEditors: this.constantEditor(),
}
return nil
}

func (this *MOpenSSLProbe) DecodeFun(em *ebpf.Map) (IEventStruct, bool) {
Expand Down

0 comments on commit 7f120bb

Please sign in to comment.