NethServer / dev

NethServer issue tracker
https://github.com/NethServer/dev/issues
63 stars 20 forks source link

Crowdsec cannot sends its email notification #6939

Closed stephdl closed 4 weeks ago

stephdl commented 1 month ago

Steps to reproduce

Expected behavior

I expect that when the client is banned, then I receive an email

Actual behavior

I do not even send an email and I find some traces in logs

May 31 16:30:37 R2-pve.rocky9-pve2.org crowdsec1[53404]: time="2024-05-31T14:30:37Z" level=error msg="rpc error: code = Unknown desc = Mail Error: mail: invalid string; Header: [From] Address: [CrowdSec <>] error, retry num 1" plugin=email_default
May 31 16:30:38 R2-pve.rocky9-pve2.org crowdsec1[53404]: time="2024-05-31T14:30:38Z" level=error msg="rpc error: code = Unknown desc = Mail Error: mail: invalid string; Header: [From] Address: [CrowdSec <>]" plugin:=email_default
May 31 16:30:38 R2-pve.rocky9-pve2.org crowdsec1[53404]: time="2024-05-31T14:30:38Z" level=info msg="Signal push: 1 signals to push"
May 31 16:30:46 R2-pve.rocky9-pve2.org crowdsec1[53404]: time="2024-05-31T14:30:46Z" level=info msg="127.0.0.1 - [Fri, 31 May 2024 14:30:46 UTC] \"GET /v1/decisions/stream HTTP/1.1 200 4.125688ms \"crowdsec-firewall-bouncer/v0.0.28-debian-pragmatic-af6e7e25822c2b1a02168b99ebbf8458bc6728e5\" \""

This is due because the sender_email is empty, since we use the mail server as provider without authentication, the from field is empty

Python 3.11.7 (main, Jan 22 2024, 00:00:00) [GCC 11.4.1 20231218 (Red Hat 11.4.1-3)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import agent 
>>> agent.get_smarthost_settings(agent.redis_connect(use_replica=True))
{'port': 25, 'host': '10.5.4.1', 'username': '', 'password': '', 'enabled': True, 'encrypt_smtp': 'none', 'tls_verify': False}

see https://github.com/NethServer/ns8-crowdsec/blob/72013f70a71fe7b3dcd6ac8247ce4bc7e55bf6e1/imageroot/bin/expand-smarthost#L39

Components

crowdsec 1.0.8

See also

https://community.nethserver.org/t/crowdsec-does-not-send-notifications/23740


thank transocean

stephdl commented 4 weeks ago

QA

DavidePrincipi commented 4 weeks ago

Released https://github.com/NethServer/ns8-crowdsec/releases/tag/1.0.9