Skip to content

Comments

improved handling of @ signs#5

Open
spotrh wants to merge 1 commit intoToddAtkins:masterfrom
spotrh:mailat
Open

improved handling of @ signs#5
spotrh wants to merge 1 commit intoToddAtkins:masterfrom
spotrh:mailat

Conversation

@spotrh
Copy link

@spotrh spotrh commented Nov 9, 2018

This was reported against swatch here: https://bugzilla.redhat.com/show_bug.cgi?id=1646480

The swatchdog man page for the mail command shows the syntax as:
mail [addresses=address:address:...][,subject=your_text_here]

However, if the email address contains an '@' sign, then swatchdog fails to start and gives an error. (A similar error will also occur if the 'subject' contains an '@' sign.)

Steps to Reproduce:

  1. As root create the ~/.swatchdogrc file:
    watchfor /error/
    mail addresses=abc@example.com
  2. Run: swatchdog -c $HOME/.swatchdogrc -t /var/log/messages
  3. Modify the .swatchdogrc file, and remove just the 'addresses=' part.
    So the line is now 'mail abc@example.com'
  1. Rerun the swatchdog command. It will work this time.
    This is despite not following the man page 'mail' command syntax. However,
    further down the man page shows a use of 'mail' which itself does not include
    'addresses='. (mail=sysad-pager@somehost.somedomain,when=1-6:8-17)

Actual results:
Swatchdog stops, showing the following error message:

Global symbol "@example" requires explicit package name at /root/.swatchdog_script.30106 line 97.
Execution of /root/.swatchdog_script.30106 aborted due to compilation errors.

Expected results:
No error should show when starting swatchdog.

Additional info:

The problem is that the 'addresses=' and 'subject=' parts do not cater for '@' signs in them. When 'addresses=' is left out, then swatchdog does handle them because it goes through a different bit of code.

This PR corrects this. It is only a few lines long.
It has been tested with one and multiple addresses, and the subject line, with an '@' in it has been tested too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant