Module: check_mk
Branch: master
Commit: 1afa42765f95d0169dbb43b90d8495f9c745b5d5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1afa42765f95d0…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Feb 29 11:01:56 2016 +0100
#3253 FIX sms: notification script sms now handles single quotes in the message in the
right way
---
.werks/3253 | 10 ++++++++++
ChangeLog | 3 +++
notifications/sms | 5 +++--
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/.werks/3253 b/.werks/3253
new file mode 100644
index 0000000..a3f629b
--- /dev/null
+++ b/.werks/3253
@@ -0,0 +1,10 @@
+Title: sms: notification script sms now handles single quotes in the message in the right
way
+Level: 1
+Component: notifications
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1456740033
+
+
diff --git a/ChangeLog b/ChangeLog
index d2791a1..5d1f7bc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -74,6 +74,9 @@
* 2998 FIX: Fixed broken WATO rules where content is dynamically loaded...
* 3246 FIX: Fix link for editing a BI aggregation after coming back from the details
of another aggregation...
+ Notifications:
+ * 3253 FIX: sms: notification script sms now handles single quotes in the message in
the right way
+
BI:
* 3247 FIX: Do not allow multiple BI aggregates with the same title...
diff --git a/notifications/sms b/notifications/sms
index 20d0d01..5512028 100755
--- a/notifications/sms
+++ b/notifications/sms
@@ -87,16 +87,17 @@ elif notification_type == "CUSTOM":
message += " " + os.environ['NOTIFY_NOTIFICATIONCOMMENT']
recipient = os.environ['NOTIFY_CONTACTPAGER'].replace(" ",
"")
+quoted_message = "'" + message.replace("'",
"'\"'\"'") + "'"
if send_path:
- if os.system("%s %s '%s'" % (send_path, recipient, message[:160]))
>> 8 != 0:
+ if os.system("%s %s %s" % (send_path, recipient, quoted_message[:160]))
>> 8 != 0:
sys.exit(1)
elif spool_dir:
# On some distros, like debian, smstools does not ship with the sendsms/smssend
helper
# script. On this distro, simply drop the SMS in the outgoing spool directory.
import tempfile, shutil
fd, path = tempfile.mkstemp(prefix = 'cmk_sms_')
- os.write(fd, 'To: %s\n\n%s' % (recipient, message))
+ os.write(fd, 'To: %s\n\n%s' % (recipient, quoted_message))
os.close(fd)
os.chmod(path, 0660)
filename = path.split('/')[-1]