summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2020-03-31 21:44:55 +0200
committerSuren A. Chilingaryan <csa@suren.me>2020-03-31 21:44:55 +0200
commitc0e86ac02247a0c28fa297c750cf8b5038b03c10 (patch)
treed3701b51558e37226dded0217482f621829c6f84
parent09013760d27c32a793b3738833a7beb0e2fdd6ee (diff)
downloadconky-c0e86ac02247a0c28fa297c750cf8b5038b03c10.tar.gz
conky-c0e86ac02247a0c28fa297c750cf8b5038b03c10.tar.bz2
conky-c0e86ac02247a0c28fa297c750cf8b5038b03c10.tar.xz
conky-c0e86ac02247a0c28fa297c750cf8b5038b03c10.zip
Support special symbols in ADEI password
-rw-r--r--lib/adei/adei.sh21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/adei/adei.sh b/lib/adei/adei.sh
index fa9dfc3..2bdc150 100644
--- a/lib/adei/adei.sh
+++ b/lib/adei/adei.sh
@@ -13,6 +13,14 @@ adei_default_timeout=${default_timeout:-120}
shopt -s nocasematch;
+function adei_curl {
+ if [ -n "$adei_auth" ]; then
+ curl -u "$adei_auth" "$@"
+ else
+ curl "$@"
+ fi
+}
+
# Auth with redirect (-L/--location-trusted) not working. Credentials are lost on hops.
function adei_query {
local resp
@@ -21,12 +29,12 @@ function adei_query {
local err=0
if [ "$2" == "ecode" ]; then
url="$1&mysql=master"
-# resp=$(curl --proxy "" -f -m "$timeout" "$url" 2>&1 | grep "returned error")
- resp=$(curl --proxy "" --location-trusted -sf -m "$timeout" -w "%{http_code}" -o /dev/null "$url" 2>&1);
+# resp=$(adei_curl --proxy "" -f -m "$timeout" "$url" 2>&1 | grep "returned error")
+ resp=$(adei_curl --proxy "" --location-trusted -sf -m "$timeout" -w "%{http_code}" -o /dev/null "$url" 2>&1);
[ -z "$resp" -o "$resp" = "000" ] && resp="10" # error code 1
elif [ "$2" == "emsg" ]; then
url="$1&mysql=master"
- resp=$(curl --proxy "" --location-trusted -f -m "$timeout" "$url" 2>&1 | grep -o "curl.*")
+ resp=$(adei_curl --proxy "" --location-trusted -f -m "$timeout" "$url" 2>&1 | grep -o "curl.*")
[ -z "$resp" ] && resp="No response from"
else
if [ "$2" == "slave" ]; then
@@ -35,7 +43,7 @@ function adei_query {
url="$1&mysql=master"
fi
- resp=$(curl --proxy "" --location-trusted -sf -m "$timeout" "$url"); err=$?
+ resp=$(adei_curl --proxy "" --location-trusted -sf -m "$timeout" "$url"); err=$?
if [ $err -ne 0 ]; then
resp=$(adei_query "$1" "ecode" "$timeout")
err=$(($(($resp / 10)) + $(($resp % 10))))
@@ -61,7 +69,7 @@ function adei_format_query {
local url="${6:-$adei_url}"
auth=""
- [ $with_auth -gt 0 ] && auth="$adei_auth"
+ [ $with_auth -gt 0 ] && auth="${adei_auth}@"
if [[ "$query" =~ \? ]]; then
echo "http://${auth}${url}/${query}${source}"
else
@@ -70,7 +78,7 @@ function adei_format_query {
}
function adei_simple_query {
- local req=$(adei_format_query 1 "$@")
+ local req=$(adei_format_query 0 "$@")
local database=${2:-master}
adei_query "$req" $database "$timeout"; err=$?
return $err
@@ -246,7 +254,6 @@ function adei_init_ {
# In some case we miss here "setup", but surely then the password is resolved host-based
adei_auth=$(adei_resolve_id "security/adei.txt" "$id" "$host" "$setup")
- [ -n "$adei_auth" ] && adei_auth="$adei_auth@"
# Now build ADEI url
adei_setup="$setup"