Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install / run cscli on armv6l architecture (raspberry pi B) with compiled binaries #2988

Open
arthurlutz opened this issue May 7, 2024 · 7 comments
Labels
kind/bug Something isn't working needs/triage

Comments

@arthurlutz
Copy link

What happened?

Installing cscli using debian packages or releases.tgz fails on segfault

What did you expect to happen?

I would expect the wizard.sh to detect the architecture and either install the correct binary or explain to the user that this architecture is not supported.

How can we reproduce it (as minimally and precisely as possible)?

apt install cscli
[snip]
Selecting previously unselected package crowdsec.
(Reading database ... 62186 files and directories currently installed.)
Preparing to unpack .../crowdsec_1.5.2_armhf.deb ...
locale: Cannot set LC_ALL to default locale: No such file or directory
You can always run the configuration again interactively by using '/usr/share/crowdsec/wizard.sh -c
Unpacking crowdsec (1.5.2) ...
Setting up crowdsec (1.5.2) ...
locale: Cannot set LC_ALL to default locale: No such file or directory
Updating hub
/var/lib/dpkg/info/crowdsec.postinst: line 105: 30216 Segmentation fault      /usr/bin/cscli hub update
dpkg: error processing package crowdsec (--configure):
 installed crowdsec package post-installation script subprocess returned error exit status 139
Errors were encountered while processing:
 crowdsec
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@pi:~# /usr/bin/cscli 
Segmentation fault
root@pi:~# strace /usr/bin/cscli 
execve("/usr/bin/cscli", ["/usr/bin/cscli"], 0xbede1bd0 /* 31 vars */) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=NULL} ---
+++ killed by SIGSEGV +++
Segmentation fault
root@pi:~# file /usr/bin/cscli 
/usr/bin/cscli: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, BuildID[sha1]=995724f850dfe5272d1e8c4d64908082b201afe5, for GNU/Linux 3.2.0, stripped

Switched to trying with the tgz release :

wget https://github.com/crowdsecurity/crowdsec/releases/latest/download/crowdsec-release.tgz
tar xzvf crowdsec-release.tgz
cd crowdsec-v* && sudo ./wizard.sh -i
[snip]
./wizard.sh: line 687: /usr/local/bin/cscli: cannot execute binary file: Exec format error
pi@pi:~/crowdsec-v1.6.1 $ file /usr/local/bin/cscli
/usr/local/bin/cscli: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=61910f0fe1f76c051ddabc7dbd92b7c86e57a49b, for GNU/Linux 3.2.0, stripped
pi@pi:~/crowdsec-v1.6.1 $ uname -a
Linux pi 6.1.21+ #1642 Mon Apr  3 17:19:14 BST 2023 armv6l GNU/Linux
pi@pi:~/crowdsec-v1.6.1 $ cat /proc/cpuinfo 
processor	: 0
model name	: ARMv6-compatible processor rev 7 (v6l)
BogoMIPS	: 697.95
Features	: half thumb fastmult vfp edsp java tls 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xb76
CPU revision	: 7

Hardware	: BCM2835
Revision	: 0002
Serial		: 0000000026e833f9
Model		: Raspberry Pi Model B Rev 1

Anything else we need to know?

No response

Crowdsec version

$ cscli version
-bash: /usr/local/bin/cscli: cannot execute binary file: Exec format error
$ /usr/bin/cscli version
Segmentation fault

OS version

# On Linux:
$ cat /etc/os-release
root@pi:~# cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 12 (bookworm)"
NAME="Raspbian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

$ uname -a
Linux pi 6.1.21+ #1642 Mon Apr  3 17:19:14 BST 2023 armv6l GNU/Linux

# On Windows:
C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture
# paste output here

Enabled collections and parsers

$ cscli hub list -o raw
# paste output here

Acquisition config

```console # On Linux: $ cat /etc/crowdsec/acquis.yaml /etc/crowdsec/acquis.d/* # paste output here

On Windows:

C:> Get-Content C:\ProgramData\CrowdSec\config\acquis.yaml

paste output here

Config show

$ cscli config show
# paste output here

Prometheus metrics

$ cscli metrics
# paste output here

Related custom configs versions (if applicable) : notification plugins, custom scenarios, parsers etc.

@arthurlutz arthurlutz added the kind/bug Something isn't working label May 7, 2024
Copy link

github-actions bot commented May 7, 2024

@arthurlutz: Thanks for opening an issue, it is currently awaiting triage.

In the meantime, you can:

  1. Check Crowdsec Documentation to see if your issue can be self resolved.
  2. You can also join our Discord.
  3. Check Releases to make sure your agent is on the latest version.
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@arthurlutz
Copy link
Author

trying to build from source gives me :

GOARCH='arm' GOARM='6' GOOS='linux' make build
Building v1.6.2-rc1-11-ga2dcc0ef (a2dcc0ef) dynamic for linux/arm
Using C++ regexp library

go build -ldflags "-s -w  -X 'github.com/crowdsecurity/go-cs-lib/version.Version=v1.6.2-rc1-11-ga2dcc0ef' -X 'github.com/crowdsecurity/go-cs-lib/version.BuildDate=2024-05-07_09:47:08' -X 'github.com/crowdsecurity/go-cs-lib/version.Tag=a2dcc0ef' -X 'github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=alphaga' -X 'github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultConfigDir=/etc/crowdsec' -X 'github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultDataDir=/var/lib/crowdsec/data' -X 'github.com/crowdsecurity/crowdsec/pkg/cwversion.Libre2=C++'" -trimpath -tags netgo,osusergo,sqlite_omit_load_extension,re2_cgo  -o crowdsec
package github.com/crowdsecurity/crowdsec/cmd/crowdsec
	imports github.com/crowdsecurity/crowdsec/pkg/acquisition
	imports github.com/crowdsecurity/crowdsec/pkg/acquisition/modules/appsec
	imports github.com/crowdsecurity/crowdsec/pkg/appsec
	imports github.com/crowdsecurity/crowdsec/pkg/exprhelpers
	imports github.com/wasilibs/go-re2
	imports github.com/wasilibs/go-re2/internal
	imports github.com/wasilibs/go-re2/internal/cre2: build constraints exclude all Go files in /home/arthur/go/pkg/mod/github.com/wasilibs/go-re2@v1.3.0/internal/cre2
make[1]: *** [Makefile:25: build] Error 1
make: *** [Makefile:203: crowdsec] Error 2

@LaurenceJJones
Copy link
Contributor

LaurenceJJones commented May 7, 2024

When compiling on the device, could you ensure the dependencies listed here are installed?

https://docs.crowdsec.net/docs/next/getting_started/install_source#dependencies

If you plan to compile on another machine then transfer it then you must aim for static build

We support any/any via our official repositories, the debian mantainer has stopped issuing updates (hence the 1.5.2 instead of the latest 1.6.1)

https://docs.crowdsec.net/u/getting_started/installation/linux#repository-installation

@arthurlutz
Copy link
Author

❯ dpkg -l pkg-config make libre2-dev g++ gcc
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name             Version           Architecture Description
+++-================-=================-============-==================================================================
ii  g++              4:13.2.0-7ubuntu1 amd64        GNU C++ compiler
ii  gcc              4:13.2.0-7ubuntu1 amd64        GNU C compiler
ii  libre2-dev:amd64 20230301-3build1  amd64        efficient, principled regular expression library, development kit
ii  make             4.3-4.1build2     amd64        utility for directing compilation
ii  pkg-config:amd64 1.8.1-2build1     amd64        manage compile and link flags for libraries (transitional package)

Seems correct.

Trying the direct go build approach without the make file fails with :

❯ pwd
/home/arthur/local/crowdsec/cmd/crowdsec-cli
❯ GOARCH='arm' GOARM='6' GOOS='linux'  go build
# github.com/crowdsecurity/crowdsec/pkg/database
../../pkg/database/alerts.go:754:38: undefined: sqlite3.Error
../../pkg/database/alerts.go:755:35: undefined: sqlite3.ErrBusy

@blotus
Copy link
Member

blotus commented May 7, 2024

Hello,

Can you try to build with make BUILD_RE2_WASM=1 BUILD_STATIC=1 ?

@arthurlutz
Copy link
Author

I forgot : thanks for both your responses and taking the time to look into this issue.

With the added build flags I get the error I get with a go build :

GOARCH='arm' GOARM='5' GOOS='linux' make build BUILD_RE2_WASM=1 BUILD_STATIC=1 

Building v1.6.2-rc1-11-ga2dcc0ef-dirty (a2dcc0ef) static for linux/arm
Using C++ regexp library

go build -ldflags "-s -w -extldflags '-static' -X 'github.com/crowdsecurity/go-cs-lib/version.Version=v1.6.2-rc1-11-ga2dcc0ef-dirty' -X 'github.com/crowdsecurity/go-cs-lib/version.BuildDate=2024-05-07_11:13:09' -X 'github.com/crowdsecurity/go-cs-lib/version.Tag=a2dcc0ef' -X 'github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=alphaga' -X 'github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultConfigDir=/etc/crowdsec' -X 'github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultDataDir=/var/lib/crowdsec/data'" -trimpath -tags netgo,osusergo,sqlite_omit_load_extension  -o crowdsec
# github.com/crowdsecurity/crowdsec/pkg/database
../../pkg/database/alerts.go:754:38: undefined: sqlite3.Error
../../pkg/database/alerts.go:755:35: undefined: sqlite3.ErrBusy
make[1]: *** [Makefile:25: build] Error 1
make: *** [Makefile:203: crowdsec] Error 2

It seems that the dependency is there :

❯ find ~/go/ | grep sqlite | grep v1.14.16
/home/arthur/go/pkg/mod/cache/download/github.com/mattn/go-sqlite3/@v/v1.14.16.zip
/home/arthur/go/pkg/mod/cache/download/github.com/mattn/go-sqlite3/@v/v1.14.16.info
/home/arthur/go/pkg/mod/cache/download/github.com/mattn/go-sqlite3/@v/v1.14.16.ziphash
/home/arthur/go/pkg/mod/cache/download/github.com/mattn/go-sqlite3/@v/v1.14.16.mod
/home/arthur/go/pkg/mod/cache/download/github.com/mattn/go-sqlite3/@v/v1.14.16.lock
/home/arthur/go/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16
/home/arthur/go/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16/sqlite3_opt_fts5.go
/home/arthur/go/pkg/mod/github.com/mattn/go-sqlite3@v1.14.16/sqlite3_trace.go
[snip]

@rahuljawale
Copy link

@arthurlutz I am in the same boat and was wondering if you were able to find a fix for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working needs/triage
Projects
None yet
Development

No branches or pull requests

4 participants