diff --git a/icinga_host_notify_remote.py b/icinga_host_notify_remote.py index b5816ce..095d189 100755 --- a/icinga_host_notify_remote.py +++ b/icinga_host_notify_remote.py @@ -4,13 +4,14 @@ import logging import os import sys import subprocess +import shlex from icinga_host_notify import assemble_sms import sms_functions def main(): sms_msg = assemble_sms() sms_number = os.environ.get('USERMOBILE') - logger.info("Remote - Sending SMS to %s: %s", sms_number, sms_msg) +# logger.info("Remote - Sending SMS to %s: %s", sms_number, sms_msg) hostname = sys.argv[1] @@ -21,6 +22,9 @@ def main(): while not success and retries < max_retries: retries += 1 try: + # Escape message and number for remote shell + sms_msg = shlex.quote(sms_msg) + sms_number = shlex.quote(sms_number) # Contact remote host subprocess.run([ '/usr/bin/ssh', hostname, '/opt/sms/send_sms.py', sms_msg, sms_number ], check=True) except: