@cryptotaxi247 / netdata-1 / commits / a409008f3

Update mechanism to be more generic.

This updates the mechanism of passing extra options to cURL to be more generic as requested in PR feedback. THis allows the user to pass arbitrary options to cURL. and simplifies the associated code in alarm-notify.sh significantly.

Austin S. Hemmelgarn committed Mar 1, 2018 at 14:46 UTC a409008f3799ba20d8d26f231c28a21c06fe7b86
2 files changed +9 -18
conf.d/health_alarm_notify.conf
+7 -9
@@ -67,15 +67,13 @@ nc=""
67 # In some cases, you may need to change what options get passed to an
68 # external command. Such cases are covered here.
69
70 -# Control TLS certificate validation for cURL.
71 -# If set to yes, disable certificatie validation.
72 -# Otherwise, cURL will validate TLS certificates normally.
73 -# ******************************WARNING****************************************
74 -# Disabling this validation by setting the below variable to 'yes'
75 -# makes it trivial for someone to block notification delivery through most
76 -# mechanisms other than email and IRC, and may additionally leak sensitive
77 -# information about the system state.
78 -curl_insecure="no"
70 +# Extra options to pass to curl. In most cases, you shouldn't need to add anything
71 +# to this. If you're having issues with HTTPS connections, you might try adding
72 +# '--insecure' here, but be warned that it will make it much easier for
73 +# third-parties to block notification delivery, and may allow disclosure
74 +# of potentially sensitive information.
75 +curl_options=""
76 +#curl_options="--insecure"
77
78 #------------------------------------------------------------------------------
79 # NOTE ABOUT RECIPIENTS
plugins.d/alarm-notify.sh
+2 -9
@@ -112,13 +112,6 @@ docurl() {
112 return 1
113 fi
114
115 - if [ "${curl_insecure}" = "yes" ]
116 - then
117 - insecure='--insecure'
118 - else
119 - insecure=''
120 - fi
121 -
115 if [ "${debug}" = "1" ]
116 then
117 echo >&2 "--- BEGIN curl command ---"
@@ -127,7 +120,7 @@ docurl() {
120 echo >&2 "--- END curl command ---"
121
122 local out=$(mktemp /tmp/netdata-health-alarm-notify-XXXXXXXX)
130 - local code=$(${curl} ${insecure} --write-out %{http_code} --output "${out}" --silent --show-error "${@}")
123 + local code=$(${curl} ${curl_options} --write-out %{http_code} --output "${out}" --silent --show-error "${@}")
124 local ret=$?
125 echo >&2 "--- BEGIN received response ---"
126 cat >&2 "${out}"
@@ -139,7 +132,7 @@ docurl() {
132 return ${ret}
133 fi
134
142 - ${curl} ${insecure} --write-out %{http_code} --output /dev/null --silent --show-error "${@}"
135 + ${curl} ${curl_options} --write-out %{http_code} --output /dev/null --silent --show-error "${@}"
136 return $?
137 }
138