coleturner / fail2ban-slack-action

Slack Notifications for Fail2Ban
72 stars 16 forks source link

Fail2ban jail, Unexpected end of file, escape double-quote for channel #2

Closed ionescu77 closed 4 years ago

ionescu77 commented 4 years ago

Hi,

thanks for doing all the work. It's a cool implementation.

I had to escape another quote though, cause I was getting an error:

2020-02-28 14:50:34,465 fail2ban.utils          [8497]: ERROR   7f01ae0cf430 -- exec: curl -s -o /dev/null -X POST --data-urlencode "payload={\"text\": \"Fail2Ban (sshd) jail has started\", "channel\": \"#notifications\" }" 'https://hooks.slack.com/services/some-token-for-slack'
2020-02-28 14:50:34,466 fail2ban.utils          [8497]: ERROR   7f01ae0cf430 -- stderr: '/bin/sh: -c: line 0: unexpected EOF while looking for matching `"\''
2020-02-28 14:50:34,466 fail2ban.utils          [8497]: ERROR   7f01ae0cf430 -- stderr: '/bin/sh: -c: line 1: syntax error: unexpected end of file'
2020-02-28 14:50:34,466 fail2ban.utils          [8497]: ERROR   7f01ae0cf430 -- returned 1
2020-02-28 14:50:34,466 fail2ban.actions        [8497]: ERROR   Failed to start jail 'sshd' action 'slack-notify': Error starting action Jail('sshd')/slack-notify: 'Script error'

So in slack-notify.conf, just escape the double-quote for channel, so

, "channel\": 

becomes

, \"channel\": 

Best regards,

Raz