Plugins: sysutils/monit: request support for special chars in e-mail password

Created on 16 Sep 2017  路  6Comments  路  Source: opnsense/plugins

Hi,

I use a e-mail password with special chars ('!') - but monit does not accept / can't handle this.

Therefore the password needs to be in quotes - I tried single quotes which seems to work. (the monit manual states somewhere else to use double quotes...)

Here's a fix for the template (/usr/local/opnsense/service/templates/OPNsense/Monit/monitrc) - well, my first try in this language... ;):

Line 19:

 {%      set password = "password " ~ "'" ~ OPNsense.monit.general.password ~ "'" %}


Cheers,

Stephan

bug

All 6 comments

Sorry I forgot about this. Worst things first, single quotes are valid characters in the local part of email addresses, so we need to escape them before passing

https://en.wikipedia.org/wiki/Email_address#Local-part

whoopsie, I realise this is about passwords, but we should fix both things at the same time

...I didn't check, but there seems to be an evaluation of the password chars on the monit settings tab -
probably You can't insert there passwords with these chars...
Nevertheless - this way it's working AND Isurely won't change my e-mail password just because of monit :D

sorry, have not seen Your first post... this is really 'ugly' if I understand it right - dunno if monit understands this as one escapes the chars already with single chars?

how can I escape double quotes in the template?
Probably this could work in case smn has a single Quote inhis Password...?

The plugin doesn't check the password string but the monit service complains about the special character after applying the settings.
We should use double quotes here. See monit(1) section 'THE MONIT CONTROL FILE'

There are three kinds of tokens: grammar, numbers (i.e. decimal digit
sequences) and strings. Strings can be either quoted or unquoted. A
quoted string is bounded by double quotes
and may contain whitespace
(and quoted digits are treated as a string). An unquoted string is any
whitespace-delimited token, containing characters and/or numbers.

I'll implement the suggested fix but with double quotes. But it won't work if you have double quotes in your password.
Thank you :smile:

Was this page helpful?
0 / 5 - 0 ratings