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

improved handling of @ signs #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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=[email protected]
  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 [email protected]'
  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=[email protected],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