Skip to content

Commit

Permalink
Merge pull request kubearmor#222 from nam-jaehyun/master
Browse files Browse the repository at this point in the history
fix bcc arguments
  • Loading branch information
nam-jaehyun authored Jul 23, 2021
2 parents cc468fd + af15e2d commit 490bb56
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion KubeArmor/build/Dockerfile.kubearmor.selinux
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ WORKDIR /usr/src/KubeArmor/KubeArmor
COPY ./KubeArmorPolicy.yaml ./CRD/KubeArmorPolicy.yaml
COPY ./KubeArmorHostPolicy.yaml ./CRD/KubeArmorHostPolicy.yaml

RUN ./patch.sh
RUN ./patch_selinux.sh
RUN GOOS=linux GOARCH=amd64 go build -a -ldflags '-s -w' -o kubearmor main.go

### Make executable image
Expand Down
2 changes: 0 additions & 2 deletions KubeArmor/build/patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,4 @@ for GOBPF in $(ls $GOPATH/pkg/mod/github.com/iovisor);
do
echo $GOBPF
sed -i 's/C.bpf_attach_uprobe(C.int(fd), attachType, evNameCS, binaryPathCS, (C.uint64_t)(addr), (C.pid_t)(pid), 0)/C.bpf_attach_uprobe(C.int(fd), attachType, evNameCS, binaryPathCS, (C.uint64_t)(addr), (C.pid_t)(pid))/g' $GOPATH/pkg/mod/github.com/iovisor/$GOBPF/bcc/module.go
sed -i "s/C.bpf_module_create_c_from_string(cs, 2, (\*\*C.char)(\&cflagsC\[0\]), C.int(len(cflagsC)), (C.bool)(true), nil)/C.bpf_module_create_c_from_string(cs, 2, (\*\*C.char)(\&cflagsC\[0\]), C.int(len(cflagsC)), (C.bool)(true))/g" $GOPATH/pkg/mod/github.com/iovisor/$GOBPF/bcc/module.go
sed -i 's/C.bcc_func_load(bpf.p, C.int(uint32(progType)), nameCS, start, size, license, version, C.int(logLevel), logBufP, C.uint(len(logBuf)), nil)/C.bcc_func_load(bpf.p, C.int(uint32(progType)), nameCS, start, size, license, version, C.int(logLevel), logBufP, C.uint(len(logBuf)))/g' $GOPATH/pkg/mod/github.com/iovisor/$GOBPF/bcc/module.go
done
13 changes: 13 additions & 0 deletions KubeArmor/build/patch_selinux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

# download gobpf
go get -u github.com/iovisor/gobpf

# fix module.go
for GOBPF in $(ls $GOPATH/pkg/mod/github.com/iovisor);
do
echo $GOBPF
sed -i 's/C.bpf_attach_uprobe(C.int(fd), attachType, evNameCS, binaryPathCS, (C.uint64_t)(addr), (C.pid_t)(pid), 0)/C.bpf_attach_uprobe(C.int(fd), attachType, evNameCS, binaryPathCS, (C.uint64_t)(addr), (C.pid_t)(pid))/g' $GOPATH/pkg/mod/github.com/iovisor/$GOBPF/bcc/module.go
sed -i "s/C.bpf_module_create_c_from_string(cs, 2, (\*\*C.char)(\&cflagsC\[0\]), C.int(len(cflagsC)), (C.bool)(true), nil)/C.bpf_module_create_c_from_string(cs, 2, (\*\*C.char)(\&cflagsC\[0\]), C.int(len(cflagsC)), (C.bool)(true))/g" $GOPATH/pkg/mod/github.com/iovisor/$GOBPF/bcc/module.go
sed -i 's/C.bcc_func_load(bpf.p, C.int(uint32(progType)), nameCS, start, size, license, version, C.int(logLevel), logBufP, C.uint(len(logBuf)), nil)/C.bcc_func_load(bpf.p, C.int(uint32(progType)), nameCS, start, size, license, version, C.int(logLevel), logBufP, C.uint(len(logBuf)))/g' $GOPATH/pkg/mod/github.com/iovisor/$GOBPF/bcc/module.go
done

0 comments on commit 490bb56

Please sign in to comment.