[pve-devel] [Patch V2 acme 03/12] Remove unnecessary Code and fixes.
Wolfgang Link
w.link at proxmox.com
Tue Mar 31 12:08:36 CEST 2020
This Code is not required in the Proxmox environment.
We know in our environment what we have as a tool-change.
Fix Code what does not work because variable or functions are missing.
Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
src/proxmox-acme | 476 ++++++++++++-----------------------------------
1 file changed, 120 insertions(+), 356 deletions(-)
diff --git a/src/proxmox-acme b/src/proxmox-acme
index 007c58d..662c39a 100644
--- a/src/proxmox-acme
+++ b/src/proxmox-acme
@@ -1,49 +1,27 @@
#!/usr/bin/env sh
-# copied from acme.sh
-# Usage: multiline
+HTTP_HEADER="$(mktemp)"
+
_base64() {
- [ "" ] #urgly
- if [ "$1" ]; then
- _debug3 "base64 multiline:'$1'"
- ${ACME_OPENSSL_BIN:-openssl} base64 -e
- else
- _debug3 "base64 single line."
- ${ACME_OPENSSL_BIN:-openssl} base64 -e | tr -d '\r\n'
- fi
+ openssl base64 -e | tr -d '\r\n'
}
-# Usage: multiline
_dbase64() {
- if [ "$1" ]; then
- ${ACME_OPENSSL_BIN:-openssl} base64 -d -A
- else
- ${ACME_OPENSSL_BIN:-openssl} base64 -d
- fi
+ openssl base64 -d
}
# Usage: hashalg [outputhex]
# Output Base64-encoded digest
_digest() {
alg="$1"
- if [ -z "$alg" ]; then
- _usage "Usage: _digest hashalg"
- return 1
- fi
-
- outputhex="$2"
if [ "$alg" = "sha256" ] || [ "$alg" = "sha1" ] || [ "$alg" = "md5" ]; then
- if [ "$outputhex" ]; then
- ${ACME_OPENSSL_BIN:-openssl} dgst -"$alg" -hex | cut -d = -f 2 | tr -d ' '
+ if [ "$2" ]; then
+ openssl dgst -"$alg" -hex | cut -d = -f 2 | tr -d ' '
else
- ${ACME_OPENSSL_BIN:-openssl} dgst -"$alg" -binary | _base64
+ openssl dgst -"$alg" -binary | _base64
fi
- else
- _err "$alg is not supported yet"
- return 1
fi
-
}
_upper_case() {
@@ -80,11 +58,6 @@ _getfield() {
_findex="$2"
_sep="$3"
- if [ -z "$_findex" ]; then
- _usage "Usage: str field [sep]"
- return 1
- fi
-
if [ -z "$_sep" ]; then
_sep=","
fi
@@ -105,20 +78,12 @@ _getfield() {
_exists() {
cmd="$1"
- if [ -z "$cmd" ]; then
- _usage "Usage: _exists cmd"
- return 1
- fi
-
if eval type type >/dev/null 2>&1; then
- eval type "$cmd" >/dev/null 2>&1
- elif command >/dev/null 2>&1; then
+ type "$cmd" >/dev/null 2>&1
+ else command
command -v "$cmd" >/dev/null 2>&1
- else
- which "$cmd" >/dev/null 2>&1
fi
ret="$?"
- _debug3 "$cmd exists=$ret"
return $ret
}
@@ -134,59 +99,6 @@ _egrep_o() {
fi
}
-_inithttp() {
-
- if [ -z "$HTTP_HEADER" ] || ! touch "$HTTP_HEADER"; then
- HTTP_HEADER="$(_mktemp)"
- _debug2 HTTP_HEADER "$HTTP_HEADER"
- fi
-
- if [ "$__HTTP_INITIALIZED" ]; then
- if [ "$_ACME_CURL$_ACME_WGET" ]; then
- _debug2 "Http already initialized."
- return 0
- fi
- fi
-
- if [ -z "$_ACME_CURL" ] && _exists "curl"; then
- _ACME_CURL="curl -L --silent --dump-header $HTTP_HEADER "
- if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
- _CURL_DUMP="$(_mktemp)"
- _ACME_CURL="$_ACME_CURL --trace-ascii $_CURL_DUMP "
- fi
-
- if [ "$CA_PATH" ]; then
- _ACME_CURL="$_ACME_CURL --capath $CA_PATH "
- elif [ "$CA_BUNDLE" ]; then
- _ACME_CURL="$_ACME_CURL --cacert $CA_BUNDLE "
- fi
-
- if _contains "$(curl --help 2>&1)" "--globoff"; then
- _ACME_CURL="$_ACME_CURL -g "
- fi
- fi
-
- if [ -z "$_ACME_WGET" ] && _exists "wget"; then
- _ACME_WGET="wget -q"
- if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
- _ACME_WGET="$_ACME_WGET -d "
- fi
- if [ "$CA_PATH" ]; then
- _ACME_WGET="$_ACME_WGET --ca-directory=$CA_PATH "
- elif [ "$CA_BUNDLE" ]; then
- _ACME_WGET="$_ACME_WGET --ca-certificate=$CA_BUNDLE "
- fi
- fi
-
- #from wget 1.14: do not skip body on 404 error
- if [ "$_ACME_WGET" ] && _contains "$($_ACME_WGET --help 2>&1)" "--content-on-error"; then
- _ACME_WGET="$_ACME_WGET --content-on-error "
- fi
-
- __HTTP_INITIALIZED=1
-
-}
-
# body url [needbase64] [POST|PUT|DELETE] [ContentType]
_post() {
body="$1"
@@ -198,181 +110,73 @@ _post() {
if [ -z "$httpmethod" ]; then
httpmethod="POST"
fi
- _debug $httpmethod
- _debug "_post_url" "$_post_url"
- _debug2 "body" "$body"
- _debug2 "_postContentType" "$_postContentType"
- _inithttp
-
- if [ "$_ACME_CURL" ] && [ "${ACME_USE_WGET:-0}" = "0" ]; then
- _CURL="$_ACME_CURL"
- if [ "$HTTPS_INSECURE" ]; then
- _CURL="$_CURL --insecure "
- fi
- if [ "$httpmethod" = "HEAD" ]; then
- _CURL="$_CURL -I "
- fi
- _debug "_CURL" "$_CURL"
- if [ "$needbase64" ]; then
- if [ "$body" ]; then
- if [ "$_postContentType" ]; then
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url" | _base64)"
- else
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url" | _base64)"
- fi
+ _CURL="curl -L --silent --dump-header $HTTP_HEADER -g "
+ if [ "$HTTPS_INSECURE" ]; then
+ _CURL="$_CURL --insecure "
+ fi
+ if [ "$httpmethod" = "HEAD" ]; then
+ _CURL="$_CURL -I "
+ fi
+ if [ "$needbase64" ]; then
+ if [ "$body" ]; then
+ if [ "$_postContentType" ]; then
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url" | _base64)"
else
- if [ "$_postContentType" ]; then
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$_post_url" | _base64)"
- else
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$_post_url" | _base64)"
- fi
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url" | _base64)"
fi
else
- if [ "$body" ]; then
- if [ "$_postContentType" ]; then
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url")"
- else
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url")"
- fi
+ if [ "$_postContentType" ]; then
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$_post_url" | _base64)"
else
- if [ "$_postContentType" ]; then
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$_post_url")"
- else
- response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$_post_url")"
- fi
- fi
- fi
- _ret="$?"
- if [ "$_ret" != "0" ]; then
- _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $_ret"
- if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
- _err "Here is the curl dump log:"
- _err "$(cat "$_CURL_DUMP")"
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$_post_url" | _base64)"
fi
fi
- elif [ "$_ACME_WGET" ]; then
- _WGET="$_ACME_WGET"
- if [ "$HTTPS_INSECURE" ]; then
- _WGET="$_WGET --no-check-certificate "
- fi
- if [ "$httpmethod" = "HEAD" ]; then
- _WGET="$_WGET --read-timeout=3.0 --tries=2 "
- fi
- _debug "_WGET" "$_WGET"
- if [ "$needbase64" ]; then
- if [ "$httpmethod" = "POST" ]; then
- if [ "$_postContentType" ]; then
- response="$($_WGET -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --header "Content-Type: $_postContentType" --post-data="$body" "$_post_url" 2>"$HTTP_HEADER" | _base64)"
- else
- response="$($_WGET -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --post-data="$body" "$_post_url" 2>"$HTTP_HEADER" | _base64)"
- fi
+ else
+ if [ "$body" ]; then
+ if [ "$_postContentType" ]; then
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url")"
else
- if [ "$_postContentType" ]; then
- response="$($_WGET -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --header "Content-Type: $_postContentType" --method $httpmethod --body-data="$body" "$_post_url" 2>"$HTTP_HEADER" | _base64)"
- else
- response="$($_WGET -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --method $httpmethod --body-data="$body" "$_post_url" 2>"$HTTP_HEADER" | _base64)"
- fi
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" --data "$body" "$_post_url")"
fi
else
- if [ "$httpmethod" = "POST" ]; then
- if [ "$_postContentType" ]; then
- response="$($_WGET -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --header "Content-Type: $_postContentType" --post-data="$body" "$_post_url" 2>"$HTTP_HEADER")"
- else
- response="$($_WGET -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --post-data="$body" "$_post_url" 2>"$HTTP_HEADER")"
- fi
- elif [ "$httpmethod" = "HEAD" ]; then
- if [ "$_postContentType" ]; then
- response="$($_WGET --spider -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --header "Content-Type: $_postContentType" --post-data="$body" "$_post_url" 2>"$HTTP_HEADER")"
- else
- response="$($_WGET --spider -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --post-data="$body" "$_post_url" 2>"$HTTP_HEADER")"
- fi
+ if [ "$_postContentType" ]; then
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "Content-Type: $_postContentType" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$_post_url")"
else
- if [ "$_postContentType" ]; then
- response="$($_WGET -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --header "Content-Type: $_postContentType" --method $httpmethod --body-data="$body" "$_post_url" 2>"$HTTP_HEADER")"
- else
- response="$($_WGET -S -O - --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" --method $httpmethod --body-data="$body" "$_post_url" 2>"$HTTP_HEADER")"
- fi
+ response="$($_CURL --user-agent "$USER_AGENT" -X $httpmethod -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$_post_url")"
fi
fi
- _ret="$?"
- if [ "$_ret" = "8" ]; then
- _ret=0
- _debug "wget returns 8, the server returns a 'Bad request' response, lets process the response later."
- fi
- if [ "$_ret" != "0" ]; then
- _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $_ret"
- fi
- _sed_i "s/^ *//g" "$HTTP_HEADER"
- else
- _ret="$?"
- _err "Neither curl nor wget is found, can not do $httpmethod."
fi
- _debug "_ret" "$_ret"
+ _ret="$?"
+ if [ "$_ret" != "0" ]; then
+ _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $_ret"
+ fi
printf "%s" "$response"
return $_ret
}
# url getheader timeout
_get() {
- _debug GET
url="$1"
onlyheader="$2"
t="$3"
- _debug url "$url"
- _debug "timeout=$t"
- _inithttp
-
- if [ "$_ACME_CURL" ] && [ "${ACME_USE_WGET:-0}" = "0" ]; then
- _CURL="$_ACME_CURL"
- if [ "$HTTPS_INSECURE" ]; then
- _CURL="$_CURL --insecure "
- fi
- if [ "$t" ]; then
- _CURL="$_CURL --connect-timeout $t"
- fi
- _debug "_CURL" "$_CURL"
- if [ "$onlyheader" ]; then
- $_CURL -I --user-agent "$USER_AGENT" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$url"
- else
- $_CURL --user-agent "$USER_AGENT" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$url"
- fi
- ret=$?
- if [ "$ret" != "0" ]; then
- _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $ret"
- if [ "$DEBUG" ] && [ "$DEBUG" -ge "2" ]; then
- _err "Here is the curl dump log:"
- _err "$(cat "$_CURL_DUMP")"
- fi
- fi
- elif [ "$_ACME_WGET" ]; then
- _WGET="$_ACME_WGET"
- if [ "$HTTPS_INSECURE" ]; then
- _WGET="$_WGET --no-check-certificate "
- fi
- if [ "$t" ]; then
- _WGET="$_WGET --timeout=$t"
- fi
- _debug "_WGET" "$_WGET"
- if [ "$onlyheader" ]; then
- $_WGET --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" -S -O /dev/null "$url" 2>&1 | sed 's/^[ ]*//g'
- else
- $_WGET --user-agent="$USER_AGENT" --header "$_H5" --header "$_H4" --header "$_H3" --header "$_H2" --header "$_H1" -O - "$url"
- fi
- ret=$?
- if [ "$ret" = "8" ]; then
- ret=0
- _debug "wget returns 8, the server returns a 'Bad request' response, lets process the response later."
- fi
- if [ "$ret" != "0" ]; then
- _err "Please refer to https://www.gnu.org/software/wget/manual/html_node/Exit-Status.html for error code: $ret"
- fi
+ _CURL="curl -L --silent --dump-header $HTTP_HEADER -g "
+ if [ "$HTTPS_INSECURE" ]; then
+ _CURL="$_CURL --insecure "
+ fi
+ if [ "$t" ]; then
+ _CURL="$_CURL --connect-timeout $t"
+ fi
+ if [ "$onlyheader" ]; then
+ $_CURL -I --user-agent "USER_AGENT" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$url"
else
- ret=$?
- _err "Neither curl nor wget is found, can not do GET."
+ $_CURL --user-agent "USER_AGENT" -H "$_H1" -H "$_H2" -H "$_H3" -H "$_H4" -H "$_H5" "$url"
+ fi
+ ret=$?
+ if [ "$ret" != "0" ]; then
+ _err "Please refer to https://curl.haxx.se/libcurl/c/libcurl-errors.html for error code: $ret"
fi
- _debug "ret" "$ret"
return $ret
}
@@ -381,36 +185,19 @@ _head_n() {
}
_tail_n() {
- if ! tail -n "$1" 2>/dev/null; then
- #fix for solaris
- tail -"$1"
- fi
+ tail -n "$1"
}
# stdin output hexstr splited by one space
# input:"abc"
# output: " 61 62 63"
_hex_dump() {
- if _exists od; then
- od -A n -v -t x1 | tr -s " " | sed 's/ $//' | tr -d "\r\t\n"
- elif _exists hexdump; then
- _debug3 "using hexdump"
- hexdump -v -e '/1 ""' -e '/1 " %02x" ""'
- elif _exists xxd; then
- _debug3 "using xxd"
- xxd -ps -c 20 -i | sed "s/ 0x/ /g" | tr -d ",\n" | tr -s " "
- else
- _debug3 "using _ascii_hex"
- str=$(cat)
- _ascii_hex "$str"
- fi
+ od -A n -v -t x1 | tr -s " " | sed 's/ $//' | tr -d "\r\t\n"
}
# stdin stdout
_url_encode() {
_hex_str=$(_hex_dump)
- _debug3 "_url_encode"
- _debug3 "_hex_str" "$_hex_str"
for _hex_code in $_hex_str; do
#upper case
case "${_hex_code}" in
@@ -572,6 +359,7 @@ _url_encode() {
"7a")
printf "%s" "z"
;;
+
#numbers
"30")
printf "%s" "0"
@@ -615,6 +403,7 @@ _url_encode() {
"7e")
printf "%s" "~"
;;
+
#other hex
*)
printf '%%%s' "$_hex_code"
@@ -630,35 +419,23 @@ _hmac() {
secret_hex="$2"
outputhex="$3"
- if [ -z "$secret_hex" ]; then
- _usage "Usage: _hmac hashalg secret [outputhex]"
- return 1
- fi
-
if [ "$alg" = "sha256" ] || [ "$alg" = "sha1" ]; then
if [ "$outputhex" ]; then
- (${ACME_OPENSSL_BIN:-openssl} dgst -"$alg" -mac HMAC -macopt "hexkey:$secret_hex" 2>/dev/null || ${ACME_OPENSSL_BIN:-openssl} dgst -"$alg" -hmac "$(printf "%s" "$secret_hex" | _h2b)") | cut -d = -f 2 | tr -d ' '
+ (openssl dgst -"$alg" -mac HMAC -macopt "hexkey:$secret_hex" 2>/dev/null || openssl dgst -"$alg" -hmac "$(printf "%s" "$secret_hex" | _h2b)") | cut -d = -f 2 | tr -d ' '
else
- ${ACME_OPENSSL_BIN:-openssl} dgst -"$alg" -mac HMAC -macopt "hexkey:$secret_hex" -binary 2>/dev/null || ${ACME_OPENSSL_BIN:-openssl} dgst -"$alg" -hmac "$(printf "%s" "$secret_hex" | _h2b)" -binary
+ openssl dgst -"$alg" -mac HMAC -macopt "hexkey:$secret_hex" -binary 2>/dev/null || openssl dgst -"$alg" -hmac "$(printf "%s" "$secret_hex" | _h2b)" -binary
fi
- else
- _err "$alg is not supported yet"
- return 1
fi
-
}
# domain
_is_idn() {
_is_idn_d="$1"
- _debug2 _is_idn_d "$_is_idn_d"
_idn_temp=$(printf "%s" "$_is_idn_d" | tr -d '0-9' | tr -d 'a-z' | tr -d 'A-Z' | tr -d '*.,-_')
- _debug2 _idn_temp "$_idn_temp"
[ "$_idn_temp" ]
}
# aa.com
-# aa.com,bb.com,cc.com
_idn() {
__idn_d="$1"
if ! _is_idn "$__idn_d"; then
@@ -667,20 +444,7 @@ _idn() {
fi
if _exists idn; then
- if _contains "$__idn_d" ','; then
- _i_first="1"
- for f in $(echo "$__idn_d" | tr ',' ' '); do
- [ -z "$f" ] && continue
- if [ -z "$_i_first" ]; then
- printf "%s" ","
- else
- _i_first=""
- fi
- idn --quiet "$f" | tr -d "\r\n"
- done
- else
- idn "$__idn_d" | tr -d "\r\n"
- fi
+ idn "$__idn_d" | tr -d "\r\n"
else
_err "Please install idn to process IDN names."
fi
@@ -692,55 +456,18 @@ _normalizeJson() {
# options file
_sed_i() {
- options="$1"
- filename="$2"
- if [ -z "$filename" ]; then
- _usage "Usage:_sed_i options filename"
- return 1
- fi
- _debug2 options "$options"
- if sed -h 2>&1 | grep "\-i\[SUFFIX]" >/dev/null 2>&1; then
- _debug "Using sed -i"
- sed -i "$options" "$filename"
- else
- _debug "No -i support in sed"
- text="$(cat "$filename")"
- echo "$text" | sed "$options" >"$filename"
- fi
+ sed -i "$1" "$2"
}
# sleep sec
_sleep() {
- _sleep_sec="$1"
- if [ "$__INTERACTIVE" ]; then
- _sleep_c="$_sleep_sec"
- while [ "$_sleep_c" -ge "0" ]; do
- printf "\r \r"
- __green "$_sleep_c"
- _sleep_c="$(_math "$_sleep_c" - 1)"
- sleep 1
- done
- printf "\r"
- else
- sleep "$_sleep_sec"
- fi
+ sleep "$1"
}
_stat() {
- #Linux
- if stat -c '%U:%G' "$1" 2>/dev/null; then
- return
- fi
-
- #BSD
- if stat -f '%Su:%Sg' "$1" 2>/dev/null; then
- return
- fi
-
- return 1 #error, 'stat' not found
+ stat -c '%U:%G' "$1" 2>/dev/null
}
-
_time() {
date -u "+%s"
}
@@ -751,40 +478,24 @@ _utc_date() {
# stubbed/aliased:
__green() {
- if [ "${__INTERACTIVE}${ACME_NO_COLOR:-0}" = "10" -o "${ACME_FORCE_COLOR}" = "1" ]; then
- printf '\033[1;31;32m%b\033[0m' "$1"
- return
- fi
printf -- "%b" "$1"
}
__red() {
- if [ "${__INTERACTIVE}${ACME_NO_COLOR:-0}" = "10" -o "${ACME_FORCE_COLOR}" = "1" ]; then
- printf '\033[1;31;40m%b\033[0m' "$1"
- return
- fi
printf -- "%b" "$1"
}
_log() {
- [ -z "$LOG_FILE" ] && return
- _printargs "$@" >>"$LOG_FILE"
+ return
}
_info() {
- _log "$@"
- if [ "${SYS_LOG:-$SYSLOG_LEVEL_NONE}" -ge "$SYSLOG_LEVEL_INFO" ]; then
- _syslog "$SYSLOG_INFO" "$@"
- fi
- _printargs "$@"
+ printf -- "%s" "[$(date)] " >&1
+ echo "$1"
}
_err() {
- _syslog "$SYSLOG_ERROR" "$@"
- _log "$@"
- if [ -z "$NO_TIMESTAMP" ] || [ "$NO_TIMESTAMP" = "0" ]; then
- printf -- "%s" "[$(date)] " >&2
- fi
+ printf -- "%s" "[$(date)] " >&2
if [ -z "$2" ]; then
__red "$1" >&2
else
@@ -796,11 +507,64 @@ _err() {
# key
_readaccountconf() {
- _read_conf "$ACCOUNT_CONF_PATH" "$1"
+ echo "$1"
}
# key
_readaccountconf_mutable() {
- _rac_key="$1"
- _readaccountconf "SAVED_$_rac_key"
+ _readaccountconf "$1"
+}
+
+# no-ops:
+_clearaccountconf() {
+ return
+}
+
+_cleardomainconf() {
+ return
+}
+
+_debug() {
+ return
+}
+
+_debug2() {
+ return
+}
+
+_debug3() {
+ return
+}
+
+_secure_debug() {
+ return
}
+
+_secure_debug2() {
+ return
+}
+
+_secure_debug3() {
+ return
+}
+
+_saveaccountconf() {
+ return
+}
+
+_saveaccountconf_mutable() {
+ return
+}
+
+_save_conf() {
+ return
+}
+
+_savedomainconf() {
+ return
+}
+
+_source_plugin_config() {
+ return
+}
+
--
2.20.1
More information about the pve-devel
mailing list