Unverified Commit 09bce5e6 authored by neil's avatar neil Committed by GitHub
Browse files

sync (#2297)

* Create LICENSE.md

* remove _hostingde_parse_no_strip_whitespace function as this breaks API requests

* Fix sessionid parsing on BSD

* Make travis happy. (SC2020)

* fix for https://github.com/Neilpang/acme.sh/issues/2286



* Notify mail update (#2293)

* feat: disable e-mail validation if MAIL_NOVALIDATE is set

* fix: expose _MAIL_BIN variable

* fix: call _mail_body and _mail_cmnd directly to make sure that all used variables are exposed

* fix: update notify/mail.sh
Co-Authored-By: default avatarMatej Mihevc <zuexo@users.noreply.github.com>

* fix: remove useless echo, quote eval
parent 57fc5d28
This diff is collapsed.
......@@ -4338,6 +4338,8 @@ $_authorizations_map"
if [ "$status" = "pending" ]; then
_info "Pending"
elif [ "$status" = "processing" ]; then
_info "Processing"
else
_err "$d:Verify error:$response"
_clearupwebbroot "$_currentRoot" "$removelevel" "$token"
......
......@@ -53,18 +53,6 @@ _hostingde_parse() {
fi
}
_hostingde_parse_no_strip_whitespace() {
find="${1}"
if [ "${2}" ]; then
notfind="${2}"
fi
if [ "${notfind}" ]; then
_egrep_o \""${find}\":.*" | grep -v "${notfind}" | cut -d ':' -f 2 | cut -d ',' -f 1
else
_egrep_o \""${find}\":.*" | cut -d ':' -f 2 | cut -d ',' -f 1
fi
}
_hostingde_getZoneConfig() {
_info "Getting ZoneConfig"
curZone="${fulldomain#*.}"
......@@ -97,12 +85,12 @@ _hostingde_getZoneConfig() {
zoneConfigDnsServerGroupId=$(echo "${curResult}" | _hostingde_parse "dnsServerGroupId")
zoneConfigEmailAddress=$(echo "${curResult}" | _hostingde_parse "emailAddress")
zoneConfigDnsSecMode=$(echo "${curResult}" | _hostingde_parse "dnsSecMode")
zoneConfigTemplateValues=$(echo "${curResult}" | _hostingde_parse_no_strip_whitespace "templateValues")
zoneConfigTemplateValues=$(echo "${curResult}" | _hostingde_parse "templateValues")
if [ "$zoneConfigTemplateValues" != "null" ]; then
_debug "Zone is tied to a template."
zoneConfigTemplateValuesTemplateId=$(echo "${curResult}" | _hostingde_parse "templateId")
zoneConfigTemplateValuesTemplateName=$(echo "${curResult}" | _hostingde_parse_no_strip_whitespace "templateName")
zoneConfigTemplateValuesTemplateName=$(echo "${curResult}" | _hostingde_parse "templateName")
zoneConfigTemplateValuesTemplateReplacementsIPv4=$(echo "${curResult}" | _hostingde_parse "ipv4Replacement")
zoneConfigTemplateValuesTemplateReplacementsIPv6=$(echo "${curResult}" | _hostingde_parse "ipv6Replacement")
zoneConfigTemplateValuesTemplateReplacementsMailIPv4=$(echo "${curResult}" | _hostingde_parse "mailIpv4Replacement")
......
......@@ -117,7 +117,7 @@ dns_netcup_rm() {
login() {
tmp=$(_post "{\"action\": \"login\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apipassword\": \"$NC_Apipw\", \"customernumber\": \"$NC_CID\"}}" "$end" "" "POST")
sid=$(_getfield "$tmp" "8" | sed s/\"responsedata\":\{\"apisessionid\":\"//g | sed 's/\"\}\}//g')
sid=$(echo "$tmp" | tr '{}' '\n' | grep apisessionid | cut -d '"' -f 4)
_debug "$tmp"
if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
_err "$msg"
......
......@@ -5,6 +5,7 @@
#MAIL_BIN="sendmail"
#MAIL_FROM="yyyy@gmail.com"
#MAIL_TO="yyyy@gmail.com"
#MAIL_NOVALIDATE=""
mail_send() {
_subject="$1"
......@@ -14,22 +15,28 @@ mail_send() {
_debug "_content" "$_content"
_debug "_statusCode" "$_statusCode"
MAIL_NOVALIDATE="${MAIL_NOVALIDATE:-$(_readaccountconf_mutable MAIL_NOVALIDATE)}"
if [ -n "$MAIL_NOVALIDATE" ]; then
_saveaccountconf_mutable MAIL_NOVALIDATE 1
else
_clearaccountconf "MAIL_NOVALIDATE"
fi
MAIL_BIN="${MAIL_BIN:-$(_readaccountconf_mutable MAIL_BIN)}"
if [ -n "$MAIL_BIN" ] && ! _exists "$MAIL_BIN"; then
_err "It seems that the command $MAIL_BIN is not in path."
return 1
fi
_MAIL_CMD=$(_mail_cmnd)
_MAIL_BIN=$(_mail_bin)
if [ -n "$MAIL_BIN" ]; then
_saveaccountconf_mutable MAIL_BIN "$MAIL_BIN"
else
_clearaccountconf "MAIL_BIN"
fi
_MAIL_BODY=$(_mail_body)
MAIL_FROM="${MAIL_FROM:-$(_readaccountconf_mutable MAIL_FROM)}"
if [ -n "$MAIL_FROM" ]; then
if ! _contains "$MAIL_FROM" "@"; then
if ! _mail_valid "$MAIL_FROM"; then
_err "It seems that the MAIL_FROM=$MAIL_FROM is not a valid email address."
return 1
fi
......@@ -39,7 +46,7 @@ mail_send() {
MAIL_TO="${MAIL_TO:-$(_readaccountconf_mutable MAIL_TO)}"
if [ -n "$MAIL_TO" ]; then
if ! _contains "$MAIL_TO" "@"; then
if ! _mail_valid "$MAIL_TO"; then
_err "It seems that the MAIL_TO=$MAIL_TO is not a valid email address."
return 1
fi
......@@ -55,8 +62,9 @@ mail_send() {
contenttype="text/plain; charset=utf-8"
subject="=?UTF-8?B?$(echo "$_subject" | _base64)?="
result=$({ echo "$_MAIL_BODY" | eval "$_MAIL_CMD"; } 2>&1)
result=$({ _mail_body | eval "$(_mail_cmnd)"; } 2>&1)
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
_debug "mail send error."
_err "$result"
......@@ -67,7 +75,7 @@ mail_send() {
return 0
}
_mail_cmnd() {
_mail_bin() {
if [ -n "$MAIL_BIN" ]; then
_MAIL_BIN="$MAIL_BIN"
elif _exists "sendmail"; then
......@@ -83,6 +91,10 @@ _mail_cmnd() {
return 1
fi
echo "$_MAIL_BIN"
}
_mail_cmnd() {
case $(basename "$_MAIL_BIN") in
sendmail)
if [ -n "$MAIL_FROM" ]; then
......@@ -105,16 +117,22 @@ _mail_cmnd() {
}
_mail_body() {
if [ "$_MAIL_BIN" = "sendmail" ] || [ "$_MAIL_BIN" = "ssmtp" ]; then
if [ -n "$MAIL_FROM" ]; then
echo "From: $MAIL_FROM"
fi
case $(basename "$_MAIL_BIN") in
sendmail | ssmtp)
if [ -n "$MAIL_FROM" ]; then
echo "From: $MAIL_FROM"
fi
echo "To: $MAIL_TO"
echo "Subject: $subject"
echo "Content-Type: $contenttype"
echo
fi
echo "To: $MAIL_TO"
echo "Subject: $subject"
echo "Content-Type: $contenttype"
echo
;;
esac
echo "$_content"
}
_mail_valid() {
[ -n "$MAIL_NOVALIDATE" ] || _contains "$1" "@"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment