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" ...@@ -4338,6 +4338,8 @@ $_authorizations_map"
if [ "$status" = "pending" ]; then if [ "$status" = "pending" ]; then
_info "Pending" _info "Pending"
elif [ "$status" = "processing" ]; then
_info "Processing"
else else
_err "$d:Verify error:$response" _err "$d:Verify error:$response"
_clearupwebbroot "$_currentRoot" "$removelevel" "$token" _clearupwebbroot "$_currentRoot" "$removelevel" "$token"
......
...@@ -53,18 +53,6 @@ _hostingde_parse() { ...@@ -53,18 +53,6 @@ _hostingde_parse() {
fi 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() { _hostingde_getZoneConfig() {
_info "Getting ZoneConfig" _info "Getting ZoneConfig"
curZone="${fulldomain#*.}" curZone="${fulldomain#*.}"
...@@ -97,12 +85,12 @@ _hostingde_getZoneConfig() { ...@@ -97,12 +85,12 @@ _hostingde_getZoneConfig() {
zoneConfigDnsServerGroupId=$(echo "${curResult}" | _hostingde_parse "dnsServerGroupId") zoneConfigDnsServerGroupId=$(echo "${curResult}" | _hostingde_parse "dnsServerGroupId")
zoneConfigEmailAddress=$(echo "${curResult}" | _hostingde_parse "emailAddress") zoneConfigEmailAddress=$(echo "${curResult}" | _hostingde_parse "emailAddress")
zoneConfigDnsSecMode=$(echo "${curResult}" | _hostingde_parse "dnsSecMode") 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 if [ "$zoneConfigTemplateValues" != "null" ]; then
_debug "Zone is tied to a template." _debug "Zone is tied to a template."
zoneConfigTemplateValuesTemplateId=$(echo "${curResult}" | _hostingde_parse "templateId") 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") zoneConfigTemplateValuesTemplateReplacementsIPv4=$(echo "${curResult}" | _hostingde_parse "ipv4Replacement")
zoneConfigTemplateValuesTemplateReplacementsIPv6=$(echo "${curResult}" | _hostingde_parse "ipv6Replacement") zoneConfigTemplateValuesTemplateReplacementsIPv6=$(echo "${curResult}" | _hostingde_parse "ipv6Replacement")
zoneConfigTemplateValuesTemplateReplacementsMailIPv4=$(echo "${curResult}" | _hostingde_parse "mailIpv4Replacement") zoneConfigTemplateValuesTemplateReplacementsMailIPv4=$(echo "${curResult}" | _hostingde_parse "mailIpv4Replacement")
......
...@@ -117,7 +117,7 @@ dns_netcup_rm() { ...@@ -117,7 +117,7 @@ dns_netcup_rm() {
login() { login() {
tmp=$(_post "{\"action\": \"login\", \"param\": {\"apikey\": \"$NC_Apikey\", \"apipassword\": \"$NC_Apipw\", \"customernumber\": \"$NC_CID\"}}" "$end" "" "POST") 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" _debug "$tmp"
if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then if [ "$(_getfield "$msg" "4" | sed s/\"status\":\"//g | sed s/\"//g)" != "success" ]; then
_err "$msg" _err "$msg"
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#MAIL_BIN="sendmail" #MAIL_BIN="sendmail"
#MAIL_FROM="yyyy@gmail.com" #MAIL_FROM="yyyy@gmail.com"
#MAIL_TO="yyyy@gmail.com" #MAIL_TO="yyyy@gmail.com"
#MAIL_NOVALIDATE=""
mail_send() { mail_send() {
_subject="$1" _subject="$1"
...@@ -14,22 +15,28 @@ mail_send() { ...@@ -14,22 +15,28 @@ mail_send() {
_debug "_content" "$_content" _debug "_content" "$_content"
_debug "_statusCode" "$_statusCode" _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)}" MAIL_BIN="${MAIL_BIN:-$(_readaccountconf_mutable MAIL_BIN)}"
if [ -n "$MAIL_BIN" ] && ! _exists "$MAIL_BIN"; then if [ -n "$MAIL_BIN" ] && ! _exists "$MAIL_BIN"; then
_err "It seems that the command $MAIL_BIN is not in path." _err "It seems that the command $MAIL_BIN is not in path."
return 1 return 1
fi fi
_MAIL_CMD=$(_mail_cmnd) _MAIL_BIN=$(_mail_bin)
if [ -n "$MAIL_BIN" ]; then if [ -n "$MAIL_BIN" ]; then
_saveaccountconf_mutable MAIL_BIN "$MAIL_BIN" _saveaccountconf_mutable MAIL_BIN "$MAIL_BIN"
else else
_clearaccountconf "MAIL_BIN" _clearaccountconf "MAIL_BIN"
fi fi
_MAIL_BODY=$(_mail_body)
MAIL_FROM="${MAIL_FROM:-$(_readaccountconf_mutable MAIL_FROM)}" MAIL_FROM="${MAIL_FROM:-$(_readaccountconf_mutable MAIL_FROM)}"
if [ -n "$MAIL_FROM" ]; then 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." _err "It seems that the MAIL_FROM=$MAIL_FROM is not a valid email address."
return 1 return 1
fi fi
...@@ -39,7 +46,7 @@ mail_send() { ...@@ -39,7 +46,7 @@ mail_send() {
MAIL_TO="${MAIL_TO:-$(_readaccountconf_mutable MAIL_TO)}" MAIL_TO="${MAIL_TO:-$(_readaccountconf_mutable MAIL_TO)}"
if [ -n "$MAIL_TO" ]; then 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." _err "It seems that the MAIL_TO=$MAIL_TO is not a valid email address."
return 1 return 1
fi fi
...@@ -55,8 +62,9 @@ mail_send() { ...@@ -55,8 +62,9 @@ mail_send() {
contenttype="text/plain; charset=utf-8" contenttype="text/plain; charset=utf-8"
subject="=?UTF-8?B?$(echo "$_subject" | _base64)?=" 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 if [ $? -ne 0 ]; then
_debug "mail send error." _debug "mail send error."
_err "$result" _err "$result"
...@@ -67,7 +75,7 @@ mail_send() { ...@@ -67,7 +75,7 @@ mail_send() {
return 0 return 0
} }
_mail_cmnd() { _mail_bin() {
if [ -n "$MAIL_BIN" ]; then if [ -n "$MAIL_BIN" ]; then
_MAIL_BIN="$MAIL_BIN" _MAIL_BIN="$MAIL_BIN"
elif _exists "sendmail"; then elif _exists "sendmail"; then
...@@ -83,6 +91,10 @@ _mail_cmnd() { ...@@ -83,6 +91,10 @@ _mail_cmnd() {
return 1 return 1
fi fi
echo "$_MAIL_BIN"
}
_mail_cmnd() {
case $(basename "$_MAIL_BIN") in case $(basename "$_MAIL_BIN") in
sendmail) sendmail)
if [ -n "$MAIL_FROM" ]; then if [ -n "$MAIL_FROM" ]; then
...@@ -105,7 +117,8 @@ _mail_cmnd() { ...@@ -105,7 +117,8 @@ _mail_cmnd() {
} }
_mail_body() { _mail_body() {
if [ "$_MAIL_BIN" = "sendmail" ] || [ "$_MAIL_BIN" = "ssmtp" ]; then case $(basename "$_MAIL_BIN") in
sendmail | ssmtp)
if [ -n "$MAIL_FROM" ]; then if [ -n "$MAIL_FROM" ]; then
echo "From: $MAIL_FROM" echo "From: $MAIL_FROM"
fi fi
...@@ -114,7 +127,12 @@ _mail_body() { ...@@ -114,7 +127,12 @@ _mail_body() {
echo "Subject: $subject" echo "Subject: $subject"
echo "Content-Type: $contenttype" echo "Content-Type: $contenttype"
echo echo
fi ;;
esac
echo "$_content" 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